Class: Watobo::Gui::LogoutSettings

Inherits:
FXHorizontalFrame
  • Object
show all
Defined in:
lib/watobo/gui/session_management_dialog.rb

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ LogoutSettings

Returns a new instance of LogoutSettings.


227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/watobo/gui/session_management_dialog.rb', line 227

def initialize(parent)
  @project = Watobo.project
  @signature = FXDataTarget.new('')

  super(parent, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)

  main_frame = FXHorizontalFrame.new(self, :opts => LAYOUT_FILL_Y|LAYOUT_FILL_X|FRAME_GROOVE)
  frame = FXVerticalFrame.new(main_frame, :opts => LAYOUT_FILL_Y)
  label = FXLabel.new(frame, "Logout Signatures:")

  @signature_field = FXTextField.new(frame, 40, :target => @signature, :selector => FXDataTarget::ID_VALUE, :opts => TEXTFIELD_NORMAL|LAYOUT_SIDE_LEFT)

  b_frame = FXHorizontalFrame.new(frame, :opts => LAYOUT_FILL_X)
  @addSigButton = FXButton.new(b_frame, "Add" , :opts => BUTTON_NORMAL|LAYOUT_LEFT)
  @addSigButton.connect(SEL_COMMAND, method(:addSignature))
  @remSigButton=FXButton.new(b_frame, "Remove" , :opts => BUTTON_NORMAL|LAYOUT_LEFT)
  @remSigButton.connect(SEL_COMMAND, method(:remSignature))

  list_frame = FXVerticalFrame.new(frame, :opts => LAYOUT_FILL_X|FRAME_SUNKEN, :padding => 0)
  @signature_list = FXList.new(list_frame, :opts => LIST_EXTENDEDSELECT|LAYOUT_FILL_X|LAYOUT_FILL_Y)
  @signature_list.numVisible = 25

  @signature_list.connect(SEL_COMMAND,method(:onSignatureClick))

  
  Watobo::Conf::Scanner.logout_signatures.each do |p|
      item = @signature_list.appendItem("#{p}")
      @signature_list.setItemData(item, p)
    end
  
end

Instance Method Details

#addSignature(sender, sel, id) ⇒ Object


191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/watobo/gui/session_management_dialog.rb', line 191

def addSignature(sender,sel,id)
  pattern = @signature.value
  if pattern != "" then
    begin

      # test if pattern looks like a valid regex
      if "test" =~ /#{pattern}/i then
        #looks good
      end

    rescue => bang
      puts "!!!ERROR: Bad pattern"
      showBadSignatureMessage()
      return -1
    end
    item = @signature_list.appendItem("#{@signature.value}")
    @signature_list.setItemData(item, @signature.value)
    return 0
    # item.
  end
end

#getLogoutSignaturesObject


183
184
185
186
187
188
189
# File 'lib/watobo/gui/session_management_dialog.rb', line 183

def getLogoutSignatures()
  signatures = []
  @signature_list.numItems.times do |index|
    signatures.push @signature_list.getItemData(index)
  end
  return signatures
end

#onSignatureClick(sender, sel, item) ⇒ Object


220
221
222
223
224
225
# File 'lib/watobo/gui/session_management_dialog.rb', line 220

def onSignatureClick(sender,sel,item)
  #@request_viewer.highlight(@pattern_list.getItemText(item))
  #@response_viewer.highlight(@pattern_list.getItemText(item))
  @signature.value = @signature_list.getItemText(item)
  @signature_field.handle(self, FXSEL(SEL_UPDATE, 0), nil)
end

#remSignature(sender, sel, id) ⇒ Object


213
214
215
216
217
218
# File 'lib/watobo/gui/session_management_dialog.rb', line 213

def remSignature(sender,sel,id)
  index = @signature_list.currentItem
  if  index >= 0
    @signature_list.removeItem(index)
  end
end

#showBadSignatureMessageObject


179
180
181
# File 'lib/watobo/gui/session_management_dialog.rb', line 179

def showBadSignatureMessage()
  FXMessageBox.information(self, MBOX_OK, "Wrong Signature Format", "Signature Format is wrong. Must be a valid regular expression, e.g.(<Regex>) <^Location.*action=logout>")
end