Class: Watobo::Gui::RequestBuilder
- Inherits:
-
FXVerticalFrame
- Object
- FXVerticalFrame
- Watobo::Gui::RequestBuilder
- Defined in:
- lib/watobo/gui/request_builder_frame.rb
Instance Method Summary collapse
- #clearEvents(event) ⇒ Object
- #highlight(pattern) ⇒ Object
-
#initialize(owner, opts) ⇒ RequestBuilder
constructor
A new instance of RequestBuilder.
- #parseRequest ⇒ Object
- #rawRequest ⇒ Object
- #setRequest(raw_request) ⇒ Object
- #subscribe(event, &callback) ⇒ Object
Constructor Details
#initialize(owner, opts) ⇒ RequestBuilder
Returns a new instance of RequestBuilder.
76 77 78 79 80 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 107 |
# File 'lib/watobo/gui/request_builder_frame.rb', line 76 def initialize(owner, opts) super(owner,opts) @event_dispatcher_listeners = Hash.new @last_editor = nil @tab = FXTabBook.new(self, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_RIGHT) @tab.connect(SEL_COMMAND){ @current = @editors.to_a[@tab.current][1][:editor] unless @last_editor.nil? last_request = @last_editor.rawRequest @current.setRequest(last_request) end @last_editor = @editors.to_a[@tab.current][1][:editor] #puts @current.class } @editors = {} @current = nil add_editor("Text") do |frame| Watobo::Gui::RequestEditor.new(frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK, :padding => 0) end add_editor("Table") do |frame| Watobo::Gui::TableEditorFrame.new(frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK, :padding => 0) end @current = @editors.first[1][:editor] end |
Instance Method Details
#clearEvents(event) ⇒ Object
30 31 32 |
# File 'lib/watobo/gui/request_builder_frame.rb', line 30 def clearEvents(event) @event_dispatcher_listener[event].clear end |
#highlight(pattern) ⇒ Object
62 63 64 |
# File 'lib/watobo/gui/request_builder_frame.rb', line 62 def highlight(pattern) # @text_edit.highlight(pattern) end |
#parseRequest ⇒ Object
70 71 72 73 74 |
# File 'lib/watobo/gui/request_builder_frame.rb', line 70 def parseRequest @current.parseRequest end |
#rawRequest ⇒ Object
66 67 68 |
# File 'lib/watobo/gui/request_builder_frame.rb', line 66 def rawRequest @current.rawRequest end |
#setRequest(raw_request) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/watobo/gui/request_builder_frame.rb', line 34 def setRequest(raw_request) begin # request if raw_request.is_a? String request = Watobo::Utils.text2request(raw_request) else request = Watobo::Request.new raw_request end @editors.each do |name, item| e = item[:editor] if e.setRequest(request) item[:tab_item].enable else item[:tab_item].disable end end rescue => bang puts bang puts bang.backtrace # puts request # puts "== EOE ==" end end |
#subscribe(event, &callback) ⇒ Object
26 27 28 |
# File 'lib/watobo/gui/request_builder_frame.rb', line 26 def subscribe(event, &callback) (@event_dispatcher_listeners[event] ||= []) << callback end |