Skip to content
Browse files

Trying to add the return value to the Wizard

  • Loading branch information...
1 parent 1fc181f commit aa0dc682d583d8c91c0e753801ad51b059229b55 Adam A. Gregory committed Aug 1, 2011
Showing with 25 additions and 4 deletions.
  1. +1 −1 commands/drush.rb
  2. +24 −3 lib/swt_form.rb
View
2 commands/drush.rb
@@ -14,7 +14,7 @@
cmd.key_binding = "CONTROL+D"
cmd.output = ':discard'
cmd.invoke do |context|
- DrushSettingForm::UI.testpage('test')
+ DrushSettingForm::UI.testpage()
return nil
drush = drush_init()
if !drush
View
27 lib/swt_form.rb
@@ -1,6 +1,5 @@
require 'java'
-
java_import org.eclipse.jface.wizard.WizardPage
java_import org.eclipse.swt.SWT
java_import org.eclipse.swt.layout.GridData
@@ -10,13 +9,35 @@
java_import org.eclipse.swt.widgets.Text
module DrushSettingForm
+
+ # A class to make it easy to generate UIJobs. Takes a block which is
+ # then called as the body of runInUIThread
+ class UIJob < org.eclipse.ui.progress.UIJob
+ def initialize(name, &blk)
+ super(name)
+ @block = blk
+ end
+
+ def runInUIThread(monitor)
+ @block.call(monitor)
+ return org.eclipse.core.runtime.Status::OK_STATUS
+ end
+ end
+
module UI
class << self
- def testpage(pagename)
+ def testpage()
wizard = CaptureEmployeeInfomrationWizard
dialog = org.eclipse.jface.wizard.WizardDialog.new(shell, wizard.new())
dialog.create()
- dialog.open()
+ return_value = nil
+ return_value = dialog.value if dialog.open == org.eclipse.jface.window.Window::OK
+
+ if return_value == nil
+ block_given? ? raise(SystemExit) : nil
+ else
+ block_given? ? yield(return_value) : return_value
+ end
end
private

0 comments on commit aa0dc68

Please sign in to comment.
Something went wrong with that request. Please try again.