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.


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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/watobo/gui/select_chat_dialog.rb', line 97

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


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

def selection
  @selection
end

Instance Method Details

#addSelectionObject


86
87
88
89
90
91
92
93
94
95
# File 'lib/watobo/gui/select_chat_dialog.rb', line 86

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


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/watobo/gui/select_chat_dialog.rb', line 28

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


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

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

#onTableDoubleClick(sender, sel, item) ⇒ Object


60
61
62
63
# File 'lib/watobo/gui/select_chat_dialog.rb', line 60

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

#selectChat(sender, sel, item) ⇒ Object


71
72
73
# File 'lib/watobo/gui/select_chat_dialog.rb', line 71

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

#showChat(chat) ⇒ Object


65
66
67
68
69
# File 'lib/watobo/gui/select_chat_dialog.rb', line 65

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

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

#updateTableObject


75
76
77
78
79
80
81
82
83
84
# File 'lib/watobo/gui/select_chat_dialog.rb', line 75

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