Module: SmarterMeter::Interfaces::Wizard::WizardPage

Included in:
CompletePage, PGEPage, PachubePage
Defined in:
lib/smartermeter/interfaces/swing.rb

Instance Method Summary collapse

Instance Method Details

#buildObject



324
325
326
# File 'lib/smartermeter/interfaces/swing.rb', line 324

def build
  @panel.build(:auto_create_container_gaps => false)
end

#header(title, message, controls = true) ⇒ Object

Protected: Creates a panel that includes the header at the top, in a standard wizard visual format.

It expects a block, which yields a Profligacy::Swing::LEL object to attach components and events to.

header("Title", "Message") do |c|
  c.controls = JButton.new("Hello World!")
end

title - The text to show in the header as the title. message - The text to show under the title in the header. controls - True adds a controls area to the page, false ignores it.

Defaults to true.

Returns nothing.



290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
# File 'lib/smartermeter/interfaces/swing.rb', line 290

def header(title, message, controls=true)
  layout = "
    [ (560,100)*header ]
  "
  layout += "[ controls ]" if controls

  @panel = Profligacy::Swing::LEL.new(JPanel, layout) do |c,i|
    header_layout = "
        [ <title ]
        [ <message ]
    "
    @header = Profligacy::Swing::LEL.new(JPanel, header_layout) do |cc,ii|
      cc.title = JLabel.new title
      cc.message = JEditorPane.new "text/html", message
      cc.message.background = Color::WHITE
      cc.message.editable = false
      cc.message.border = BorderFactory.createEmptyBorder(0, 30, 0, 0)
      ii.message = { :hyperlink => proc do |t, e|
          if e.event_type.to_s == "ACTIVATED"
            desktop = Desktop.getDesktop()
            uri = Java::JavaNet::URI.new(e.url.to_s)
            desktop.browse(uri)
          end
        end
      }
    end

    c.header = @header.build
    c.header.background = Color::WHITE

    yield c if block_given?
  end
end