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



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/watobo/gui/session_management_dialog.rb', line 206

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



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/watobo/gui/session_management_dialog.rb', line 170

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



162
163
164
165
166
167
168
# File 'lib/watobo/gui/session_management_dialog.rb', line 162

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

#onSignatureClick(sender, sel, item) ⇒ Object



199
200
201
202
203
204
# File 'lib/watobo/gui/session_management_dialog.rb', line 199

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



192
193
194
195
196
197
# File 'lib/watobo/gui/session_management_dialog.rb', line 192

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

#showBadSignatureMessageObject



158
159
160
# File 'lib/watobo/gui/session_management_dialog.rb', line 158

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