lib/rwd/rwd.rb in rwddialogmap-0.01 vs lib/rwd/rwd.rb in rwddialogmap-0.02
- old
+ new
@@ -55,11 +55,12 @@
if ENV["RWDTHEME"]
if ENV["RWDTHEME"] = "PDA"
load 'lib/rwdthemes/default.rwd'
end
if ENV["RWDTHEME"] = "DEFAULT"
- $stderr.puts "loading theme DEFAULT"
+ $rwdtinkerlog.info "rwd: loading theme DEFAULT"
+
load 'lib/rwdthemes/default.rwd'
end
if ENV["RWDTHEME"] = "WINDOWSLOOKALIKE"
load 'lib/rwdthemes/windowslike.rwd'
end
@@ -265,11 +266,11 @@
return res.join("\n")
end
end
class OpenTag
- def prechildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab, pda)
+ def prechildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab, pda=false)
bef = before[-1]
res << Format % ["Before", @subtype] if ($rwd_debug and not bef.nil?)
res << bef if not bef.nil?
res << Format % ["Pre", @subtype] if $rwd_debug
@@ -297,11 +298,11 @@
args = @args.deep_dup
args["nohelpbutton"] = (not help)
template = $rwd_html_1
- template = $rwd_html_PDA_1 if pda
+ # template = $rwd_html_PDA_1 if pda
res << (template(template, args))
when "p" then res << "<p #{align}>"
when "pre" then res << "<pre #{align}>"
when "big" then res << "<p #{align}><big>"
@@ -491,11 +492,11 @@
before.push(bef)
after.push(aft)
end
- def postchildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab, pda)
+ def postchildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab, pda=false)
case @subtype
when "vertical", "window", "helpwindow", "tab", "panel"
res << Format % ["BefPost", @subtype] if $rwd_debug
if @args.include?("spacing")
res << "<tr><td> </td></tr>" * (@args["spacing"].to_i)
@@ -633,11 +634,11 @@
res.join("\n")
end
end
class Text
- def prechildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab, pda)
+ def prechildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab, pda=false)
if not @text.scan(/[^ \t\r\n]/).empty?
res << Format % ["Text", ""] if $rwd_debug
res << "#{@text}"
end
end
@@ -740,12 +741,12 @@
html
end
rescue
-
- $stderr.puts "error in RWDWindow - render method"
+ $rwdtinkerlog.error "error in RWDWindow - render method"
+
end
end
class RWDMessage < RWDWindow
@@ -862,17 +863,15 @@
# Copy the vars from the window to vars. vars wil later on be copied to instance variables.
post.sort.each do |key, value|
puts "Post: #{key} -> #{value.from_html.inspect}" if $rwd_debug
- if $DEBUG
- $stderr.puts "Post: #{key} -> #{value.from_html.inspect}\n"
- end
+ $rwdtinkerlog.info "Post: #{key} -> #{value.from_html.inspect}\n"
+
vars[key] = value.from_html
- if $DEBUG
- $stderr.puts " #{value.from_html}\n"
- end
+ $rwdtinkerlog.info "rwd: #{value.from_html}\n"
+
end
# Stack handling for rwd_action, rwd_window and rwd_tab.
@rwd_action = vars["rwd_action"] if vars.include?("rwd_action")
@@ -936,28 +935,28 @@
vars["rwd_tab"] = @rwd_tab
# Copy vars from window to instance.
vars.each do |k, v|
- if $DEBUG
- $stderr.puts "Post: #{k} -> #{v}\n"
- end
+ $rwdtinkerlog.info "rwd: Post: #{k} -> #{v}\n"
+
if ((not k.empty?) and k.scan(/^rwd_/).empty? and not @rwd_ignore_vars.include?("@#{k}"))
instance_eval "@#{k} = ''"
instance_variable_set("@#{k}", vars.fetch("#{k}"))
- if $DEBUG
- $stderr.puts "Post: #{k} -> #{v}\n"
- end
+ $rwdtinkerlog.info "rwd: Post: #{k} -> #{v}\n"
+
end
end
# Callback.
if (not back) or @rwd_call_after_back.include?(@rwd_action)
unless @rwd_action =~ /^rwd_/
- puts "Method: #{@rwd_action}(#{@rwd_args.join(", ")})" if $rwd_debug
+
+ $rwdtinkerlog.debug "Method: #{@rwd_action}(#{@rwd_args})"
+
if methods.include?(@rwd_action)
method(@rwd_action).call(*@rwd_args)
else
puts "Method '%s' is not defined." % @rwd_action
end
@@ -1023,14 +1022,14 @@
if @rwd_window.empty?
@rwd_window = "main"
end
res << RWDWindow.new($rwd_gui_tinker, @rwd_window).render(pda, @rwd_refresh_action, vars, @rwd_switches, help, @rwd_tab)
rescue
- if $DEBUG
- $stderr.puts "error in render"
+
+$rwdtinkerlog.error "rwd: error in render"
+
end
- end
end
end
end
end
@@ -1103,11 +1102,13 @@
unless @rwd_timeout_thread
@rwd_timeout_thread =
Thread.new do
loop do
if Time.now - @rwd_time > @rwd_timeout
- $stderr.puts "Exiting due to timeout (#{@rwd_timeout} seconds)."
+
+ $rwdtinkerlog.info "rwd: Exiting due to timeout (#{@rwd_timeout} seconds)."
+
exit 1
end
sleep interval
end
end
@@ -1183,11 +1184,11 @@
def touch
@lastaccess = Time.now
end
- def render(res, path, post, download, downloadfile, pda)
+ def render(res, path, post, download, downloadfile, pda=false)
done = self["object"].render(res, path, post, download, downloadfile, pda, @sessionid)
res.gsub!(/\$RWD_SESSION\$/, done ? "" : "#{@sessionid}")
return done
@@ -1210,11 +1211,12 @@
# Start browser.
@browserthread =
Thread.new do
- puts "Starting the browser..."
+ $rwdtinkerlog.warn "rwd: Starting the browser..."
+
#if ENV["RWDBROWSER"].downcase =~ /iexplore/ # ???
#@ie = IE.new("http://localhost:#{port}/")
#else
browser = ENV["RWDBROWSER"].dup
@@ -1224,11 +1226,11 @@
command = "%s \"%s\"" % [browser, url]
command = browser.gsub(re, url) if browser =~ re
command.gsub!(/%port%/, port.to_s)
- system(command) or $stderr.puts "Starting of the browser failed, or the browser terminated abnormally.\nCommand => #{command}"
+ system(command) or $rwdtinkerlog.error "Starting of the browser failed, or the browser terminated abnormally.\nCommand => #{command}"
#end
puts "The browser has terminated."
end
end
@@ -1335,12 +1337,12 @@
resp["Content-Disposition"] = "attachment; filename=%s" % downloadfile unless downloadfile.empty?
resp << download
end
rescue
- puts "Sending response to browser failed."
-
+
+ $rwdtinkerlog.error "rwd: Sending response to browser failed."
@sessions.delete(session.sessionid)
end
# Eventually delete this session.
@@ -1350,11 +1352,12 @@
if @localbrowsing
resp.stop
if @browserstarted and not @browserthread.nil? and @browserthread.alive?
resp.stop do
- puts "Waiting for the browser to terminate..."
-
+
+ $rwdtinkerlog.warn "rwd: Waiting for the browser to terminate..."
+
@browserthread.join
end
end
end
end