Class: Watobo::Gui::RequestBuilder

Inherits:
FXVerticalFrame
  • Object
show all
Defined in:
lib/watobo/gui/manual_request_editor.rb

Instance Method Summary collapse

Constructor Details

#initialize(owner, opts) ⇒ RequestBuilder

Returns a new instance of RequestBuilder.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/watobo/gui/manual_request_editor.rb', line 81

def initialize(owner, opts)
   super(owner,opts)

   @event_dispatcher_listeners = Hash.new

   @tab = FXTabBook.new(self, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_RIGHT)

   FXTabItem.new(@tab, "Text", nil)
   frame = FXVerticalFrame.new(@tab, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_RAISED)
   @text_edit = Watobo::Gui::RequestEditor.new(frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK, :padding => 0)

   @text_edit.subscribe(:error) { |msg| notify(:error, msg) }

   FXTabItem.new(@tab, "Table", nil)
   frame = FXVerticalFrame.new(@tab, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_RAISED)
   frame = FXVerticalFrame.new(frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK, :padding => 0)
   @req_line = FXText.new(frame, :opts => LAYOUT_FILL_X|TEXT_FIXEDWRAP)
   @req_line.visibleRows = 1
   @req_line.backColor = @req_line.parent.backColor
   @req_line.disable
   @parm_table = TableEditor.new(frame, :opts => FRAME_SUNKEN|TABLE_COL_SIZABLE|TABLE_ROW_SIZABLE|LAYOUT_FILL_X|LAYOUT_FILL_Y|TABLE_READONLY|LAYOUT_SIDE_TOP, :padding => 2)
   # setup message chain
   @parm_table.subscribe(:hotkey_ctrl_enter){ notify(:hotkey_ctrl_enter) }
   @text_edit.subscribe(:hotkey_ctrl_enter){ notify(:hotkey_ctrl_enter) }

end

Instance Method Details

#clearEvents(event) ⇒ Object



31
32
33
# File 'lib/watobo/gui/manual_request_editor.rb', line 31

def clearEvents(event)
   @event_dispatcher_listener[event].clear
end

#highlight(pattern) ⇒ Object



56
57
58
# File 'lib/watobo/gui/manual_request_editor.rb', line 56

def highlight(pattern)
   @text_edit.highlight(pattern)
end

#parseRequestObject



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/watobo/gui/manual_request_editor.rb', line 69

def parseRequest

   case @tab.current
   when 0

      @text_edit.parseRequest
   when 1

      @parm_table.parseRequest
   end
end

#rawRequestObject



60
61
62
63
64
65
66
67
# File 'lib/watobo/gui/manual_request_editor.rb', line 60

def rawRequest
   case @tab.current
   when 0
      @text_edit.rawRequest
   when 1
      @parm_table.rawRequest
   end
end

#setRequest(request) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/watobo/gui/manual_request_editor.rb', line 35

def setRequest(request)
   begin
      @text_edit.setText(request)
      @parm_table.setRequest(request)

      if request.is_a? Array
         text = "#{request.first}"
      else
         text = request.slice(/.* HTTP\/\d\.\d/)
      end
      #text.gsub!(/\?.*/,"")
      #text.gsub!(/ HTTP\/.*/,"")
      @req_line.setText(text.strip)
   rescue => bang
      puts bang
      # puts bang.backtrace if $DEBUG
      # puts request
      # puts "== EOE =="
   end
end

#subscribe(event, &callback) ⇒ Object



27
28
29
# File 'lib/watobo/gui/manual_request_editor.rb', line 27

def subscribe(event, &callback)
   (@event_dispatcher_listeners[event] ||= []) << callback
end