Class: Watobo::Gui::LoginScriptSettings
- Inherits:
-
FXVerticalFrame
- Object
- FXVerticalFrame
- Watobo::Gui::LoginScriptSettings
- Defined in:
- lib/watobo/gui/session_management_dialog.rb
Instance Method Summary collapse
- #addRequest(chat) ⇒ Object
- #getLoginScriptIds ⇒ Object
-
#initialize(parent) ⇒ LoginScriptSettings
constructor
A new instance of LoginScriptSettings.
- #onTableClick(sender, sel, item) ⇒ Object
- #removeRequest(sender, sel, item) ⇒ Object
- #showChat(chat) ⇒ Object
- #startSelectChatDialog(sender, sel, item) ⇒ Object
Constructor Details
#initialize(parent) ⇒ LoginScriptSettings
Returns a new instance of LoginScriptSettings.
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 |
# File 'lib/watobo/gui/session_management_dialog.rb', line 544 def initialize(parent) @project = Watobo.project @table_filter = FXDataTarget.new('') @sel_row = -1 super(parent, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y) # main_splitter = FXSplitter.new(self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X|SPLITTER_HORIZONTAL|LAYOUT_FILL_Y|SPLITTER_TRACKING) # left_frame = FXVerticalFrame.new(main_splitter, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_GROOVE, :width => 400, :padding => 0) # right_frame = FXVerticalFrame.new(main_splitter, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :width => 200, :padding => 0) #chat_filter_frame = FXHorizontalFrame.new(left_frame, :opts => LAYOUT_FILL_X) #FXLabel.new(chat_filter_frame, "Filter") #@filter_text_field = FXTextField.new(chat_filter_frame, 20, @table_filter, FXDataTarget::ID_VALUE, FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X) #chat_table_frame = FXVerticalFrame.new(left_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y) splitter = FXSplitter.new(self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X|SPLITTER_VERTICAL|LAYOUT_FILL_Y|SPLITTER_TRACKING) script_frame = FXVerticalFrame.new(splitter, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_GROOVE, :height => 300,:padding => 0) frame = FXHorizontalFrame.new(script_frame, :opts => LAYOUT_FILL_X) label = FXLabel.new(frame, "Login Script Requests:") @add_button = FXButton.new(frame, "Add Request...", nil, nil, 0, FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT) @add_button.connect(SEL_COMMAND, method(:startSelectChatDialog)) @rem_button = FXButton.new(frame, "Remove Request", nil, nil, 0, FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT) @rem_button.connect(SEL_COMMAND, method(:removeRequest)) @rem_button.disable label.setFont(FXFont.new(getApp(), "helvetica", 12, FONTWEIGHT_BOLD, FONTSLANT_ITALIC, FONTENCODING_DEFAULT)) script_table_frame = FXVerticalFrame.new(script_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y) @scriptTable = ConversationTable.new(script_table_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y) @scriptTable.connect(SEL_CLICKED, method(:onTableClick)) chat_viewer_frame = FXVerticalFrame.new(splitter, LAYOUT_FILL_X|LAYOUT_FILL_Y, :height => 300, :padding => 0) tabBook = FXTabBook.new(chat_viewer_frame, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_RIGHT, :padding => 0) req_tab = FXTabItem.new(tabBook, "Request", nil) frame = FXVerticalFrame.new(tabBook, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_RAISED) @request_viewer = Watobo::Gui::SimpleTextView.new(frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN, :padding => 0) resp_tab = FXTabItem.new(tabBook, "Response", nil) frame = FXVerticalFrame.new(tabBook, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_RAISED) @response_viewer = Watobo::Gui::SimpleTextView.new(frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN, :padding => 0) if @project.respond_to? :getLoginChatIds then @project.getLoginChatIds.each do |id| chat = Watobo::Chats.get_by_id(id) addRequest(chat) end end end |
Instance Method Details
#addRequest(chat) ⇒ Object
540 541 542 |
# File 'lib/watobo/gui/session_management_dialog.rb', line 540 def addRequest(chat) @scriptTable.addChat(chat) end |
#getLoginScriptIds ⇒ Object
476 477 478 479 480 481 482 483 484 |
# File 'lib/watobo/gui/session_management_dialog.rb', line 476 def getLoginScriptIds() ids = [] @scriptTable.numRows.times do |row| # puts row ids.push @scriptTable.getRowText(row) end return ids end |
#onTableClick(sender, sel, item) ⇒ Object
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 |
# File 'lib/watobo/gui/session_management_dialog.rb', line 486 def onTableClick(sender, sel, item) begin # purge viewers @request_viewer.setText('') @response_viewer.setText('') row = item.row if row >= 0 then @scriptTable.selectRow(row, false) chatid = @scriptTable.getRowText(item.row).to_i # @logText.appendText("selected ID: (#{chatid})\n") if chatid >= 0 chat = Watobo::Chats.get_by_id(chatid) showChat(chat) if chat @sel_row = row @rem_button.enable end end rescue => bang puts "!!!ERROR: onTableClick" puts bang puts "!!!" end end |
#removeRequest(sender, sel, item) ⇒ Object
513 514 515 516 517 518 519 520 |
# File 'lib/watobo/gui/session_management_dialog.rb', line 513 def removeRequest(sender, sel, item) if @sel_row >= 0 then @scriptTable.removeRows(@sel_row) @scriptTable.killSelection(false) @rem_button.disable @sel_row = -1 end end |
#showChat(chat) ⇒ Object
469 470 471 472 473 474 |
# File 'lib/watobo/gui/session_management_dialog.rb', line 469 def showChat(chat) @request_viewer.setText(chat.request) @response_viewer.setText(chat.response) end |
#startSelectChatDialog(sender, sel, item) ⇒ Object
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 |
# File 'lib/watobo/gui/session_management_dialog.rb', line 522 def startSelectChatDialog(sender, sel, item) begin dlg = Watobo::Gui::SelectChatDialog.new(self, "Select Login Chat") if dlg.execute != 0 then chats_selected = dlg.selection.value.split(",") chats_selected.each do |chatid| chat = Watobo::Chats.get_by_id(chatid.strip) addRequest(chat) if chat end end rescue => bang puts "!!!ERROR: could not open SelectChatDialog." puts bang end end |