Class: SmarterMeter::Interfaces::Wizard::PGEPage
- Inherits:
-
Object
- Object
- SmarterMeter::Interfaces::Wizard::PGEPage
- Includes:
- WizardPage
- Defined in:
- lib/smartermeter/interfaces/swing.rb
Overview
Contains the controls and messaging for the PGE page of the wizard.
Instance Method Summary collapse
-
#initialize(buttons) ⇒ PGEPage
constructor
A new instance of PGEPage.
-
#open_pge_sign_up_flow(type, event) ⇒ Object
Opens the PG&E sign up flow for a user to create an account online if they haven’t already.
-
#password ⇒ Object
Public: Get the currently set username.
-
#username ⇒ Object
Public: Get the currently set username.
-
#validate(*ignored_args) ⇒ Object
Determines whether a user has entered both a username and password.
Methods included from WizardPage
Constructor Details
#initialize(buttons) ⇒ PGEPage
Returns a new instance of PGEPage.
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
# File 'lib/smartermeter/interfaces/swing.rb', line 335 def initialize() @global_buttons = title = "<html><b>Connect to PG&E</b></html>" = "Enter your PG&E username and password. If you don't have one," += "create one first and then enter it below." header(title, ) do |c| layout = " [ username_label | <username_field ] [ password_label | <password_field ] [ _ | create ] " @controls = Profligacy::Swing::LEL.new(JPanel, layout) do |cc,ii| cc.username_label = JLabel.new "PG&E Username:" cc.username_field = JTextField.new cc.username_field.maximum_size = Dimension.new(160,14) ii.username_field = { :key => method(:validate) } cc.password_label = JLabel.new "PG&E Password:" cc.password_field = JPasswordField.new cc.password_field.maximum_size = Dimension.new(160,14) ii.password_field = { :key => method(:validate) } cc.create = JButton.new "Create a PG&E Account" ii.create = { :action => method(:open_pge_sign_up_flow) } end c.controls = @controls.build end end |
Instance Method Details
#open_pge_sign_up_flow(type, event) ⇒ Object
Opens the PG&E sign up flow for a user to create an account online if they haven’t already.
type - The symbol representing the name of the event called event - The Java::Awt::Event that was triggered.
Returns nothing.
393 394 395 396 397 |
# File 'lib/smartermeter/interfaces/swing.rb', line 393 def open_pge_sign_up_flow(type, event) desktop = Desktop.getDesktop() uri = Java::JavaNet::URI.new("https://www.pge.com/eum/registration?TARGET=https://www.pge.com/csol") desktop.browse(uri) end |
#password ⇒ Object
Public: Get the currently set username
373 374 375 |
# File 'lib/smartermeter/interfaces/swing.rb', line 373 def password @controls.password_field.text end |
#username ⇒ Object
Public: Get the currently set username
368 369 370 |
# File 'lib/smartermeter/interfaces/swing.rb', line 368 def username @controls.username_field.text end |
#validate(*ignored_args) ⇒ Object
Determines whether a user has entered both a username and password. If they have then the next button is enabled.
Returns nothing.
381 382 383 384 |
# File 'lib/smartermeter/interfaces/swing.rb', line 381 def validate(*ignored_args) valid = @controls.password_field.text.size > 0 and @controls.username_field.text.size > 0 @global_buttons.next.enabled = valid end |