Class: Watobo::Gui::SelectChatDialog

Inherits:
FXDialogBox
  • Object
show all
Includes:
Utils
Defined in:
lib/watobo/gui/select_chat_dialog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#addDecoder, #addEncoder, #addStringInfo, #cleanupHTTP, load_plugins, #removeTags, #replace_text

Constructor Details

#initialize(owner, title) ⇒ SelectChatDialog

Returns a new instance of SelectChatDialog.



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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/watobo/gui/select_chat_dialog.rb', line 76

def initialize(owner, title)
   #  @chat_selection = []
  
   @selection = FXDataTarget.new('')

   @sel_chat = nil
   super(owner, title, DECOR_ALL, :width=>600, :height=>600)
   main_frame = FXVerticalFrame.new(self, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding => 0)
   splitter = FXSplitter.new(main_frame, LAYOUT_SIDE_TOP|LAYOUT_FILL_X|SPLITTER_VERTICAL|LAYOUT_FILL_Y|SPLITTER_TRACKING)
   top_frame = FXVerticalFrame.new(splitter, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_NONE, :height => 300, :padding => 0)

   preview_frame = FXVerticalFrame.new(splitter, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :height => 300, :padding => 0)

  
      quick_filter_gb = FXGroupBox.new(top_frame, "Quick Filter", FRAME_GROOVE|LAYOUT_FILL_X)
      quick_filter_frame = FXHorizontalFrame.new(quick_filter_gb, :opts => FRAME_NONE|LAYOUT_FILL_X, :padding => 0)
      @show_scope_only = FXCheckButton.new(quick_filter_frame, "scope only", nil, 0, ICON_BEFORE_TEXT|LAYOUT_SIDE_LEFT)
      @show_scope_only.setCheck(false)
      @show_scope_only.connect(SEL_COMMAND) { updateTable }
   table_frame = FXVerticalFrame.new(top_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_GROOVE)

   @chatTable = ConversationTable.new(table_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
   @chatTable.connect(SEL_CLICKED, method(:onTableClick))
   @chatTable.connect(SEL_DOUBLECLICKED, method(:onTableDoubleClick))


   selection_frame = FXHorizontalFrame.new(table_frame, :opts => LAYOUT_FILL_X)
   button = FXButton.new(selection_frame, "Select Chat >", nil, nil, 0, FRAME_RAISED|FRAME_THICK|LAYOUT_LEFT)
   button.connect(SEL_COMMAND, method(:selectChat))

   @selection_text = FXTextField.new(selection_frame, 20, @selection, FXDataTarget::ID_VALUE, FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X)
   #FXLabel.new(chat_filter_frame, "Filter")

   updateTable()

   tabBook = FXTabBook.new(preview_frame, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_RIGHT, :padding => 0)

   req_tab = FXTabItem.new(tabBook, "Request", nil)
   #@request_viewer = Watobo::Gui::ChatViewer.new(tabBook, FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_X|LAYOUT_FILL_Y)
   text_frame = FXVerticalFrame.new(tabBook, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK)
   @request_viewer = FXText.new(text_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
   @request_viewer.editable = false

   resp_tab = FXTabItem.new(tabBook, "Response", nil)
   text_frame = FXVerticalFrame.new(tabBook, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK)
   @response_viewer = FXText.new(text_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
   @response_viewer.editable = false

   # @response_viewer = Watobo::Gui::ChatViewer.new(tabBook, LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_GROOVE)

   button_frame = FXHorizontalFrame.new(main_frame, :opts => LAYOUT_FILL_X)
   FXButton.new(button_frame, "OK" ,
   :target => self, :selector => FXDialogBox::ID_ACCEPT,
   :opts => BUTTON_NORMAL|LAYOUT_RIGHT)
   FXButton.new(button_frame, "Cancel" ,
   :target => self, :selector => FXDialogBox::ID_CANCEL,
   :opts => BUTTON_NORMAL|LAYOUT_RIGHT)

end

Instance Attribute Details

#selectionObject (readonly)

Returns the value of attribute selection.



6
7
8
# File 'lib/watobo/gui/select_chat_dialog.rb', line 6

def selection
  @selection
end

Instance Method Details

#addSelectionObject



65
66
67
68
69
70
71
72
73
74
# File 'lib/watobo/gui/select_chat_dialog.rb', line 65

def addSelection()
   if @sel_chat then
      if @selection.value == '' then
         @selection.value = @sel_chat.to_s
      else
         @selection.value = @selection.value + "," + @sel_chat.to_s
      end
      @selection_text.handle(self, FXSEL(SEL_UPDATE, 0), nil)
   end
end

#chatClicked(item) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/watobo/gui/select_chat_dialog.rb', line 7

def chatClicked(item)
   begin
      @request_viewer.setText('')
      @response_viewer.setText('')
      #row = sender.getCurrentRow
      row = item.row
      if row >= 0 then
         @chatTable.selectRow(row)
         chatid = @chatTable.getRowText(row).to_i
         # @logText.appendText("selected ID: (#{chatid})\n")
         Watobo::Chats.each do |chat|
            if chat.id == chatid then
               @sel_chat = chatid

               showChat(chat)
               break
            end
         end
      end
   rescue => bang
      puts "!!!ERROR: onTableClick"
      puts bang
      puts "!!!"

   end
   0
end

#onTableClick(sender, sel, item) ⇒ Object



35
36
37
# File 'lib/watobo/gui/select_chat_dialog.rb', line 35

def onTableClick(sender, sel, item)
   chatClicked(item)
end

#onTableDoubleClick(sender, sel, item) ⇒ Object



39
40
41
42
# File 'lib/watobo/gui/select_chat_dialog.rb', line 39

def onTableDoubleClick(sender, sel, item)
   chatClicked(item)
   addSelection()
end

#selectChat(sender, sel, item) ⇒ Object



50
51
52
# File 'lib/watobo/gui/select_chat_dialog.rb', line 50

def selectChat(sender, sel, item)
   addSelection()
end

#showChat(chat) ⇒ Object



44
45
46
47
48
# File 'lib/watobo/gui/select_chat_dialog.rb', line 44

def showChat(chat)
   @request_viewer.setText(cleanupHTTP(chat.request))

   @response_viewer.setText(cleanupHTTP(chat.response))
end

#updateTableObject



54
55
56
57
58
59
60
61
62
63
# File 'lib/watobo/gui/select_chat_dialog.rb', line 54

def updateTable()
  chats = nil
  if @show_scope_only.checked?
    chats = Watobo::Chats.in_scope
  else
    chats = Watobo::Chats.to_a
  end
  @chatTable.showConversation( chats )

end