Class: Syskit::GUI::JobStatusDisplay
- Defined in:
- lib/syskit/gui/job_status_display.rb
Constant Summary collapse
- INTERMEDIATE_TERMINAL_STATES =
[ Roby::Interface::JOB_SUCCESS.upcase.to_s, Roby::Interface::JOB_DROPPED.upcase.to_s, Roby::Interface::JOB_FAILED.upcase.to_s, Roby::Interface::JOB_PLANNING_FAILED.upcase.to_s ]
Instance Attribute Summary collapse
-
#exceptions ⇒ Object
readonly
Returns the value of attribute exceptions.
-
#job ⇒ Object
readonly
Returns the value of attribute job.
-
#notifications ⇒ Object
readonly
Returns the value of attribute notifications.
-
#ui_drop ⇒ Object
readonly
Returns the value of attribute ui_drop.
-
#ui_job_actions ⇒ Object
readonly
Returns the value of attribute ui_job_actions.
-
#ui_notifications ⇒ Object
readonly
Returns the value of attribute ui_notifications.
-
#ui_restart ⇒ Object
readonly
Returns the value of attribute ui_restart.
-
#ui_start ⇒ Object
readonly
Returns the value of attribute ui_start.
-
#ui_state ⇒ Object
readonly
Returns the value of attribute ui_state.
Instance Method Summary collapse
- #connect_to_hooks ⇒ Object
- #create_ui ⇒ Object
- #enterEvent(event) ⇒ Object
- #hide_job_actions ⇒ Object
-
#initialize(job, batch_manager) ⇒ JobStatusDisplay
constructor
A new instance of JobStatusDisplay.
- #keyPressEvent(event) ⇒ Object
- #keyReleaseEvent(event) ⇒ Object
- #label ⇒ Object
- #leaveEvent(event) ⇒ Object
- #make_actions_immediate(enable) ⇒ Object
- #mousePressEvent(event) ⇒ Object
- #mouseReleaseEvent(event) ⇒ Object
- #notify(key, text) ⇒ Object
- #show_actions=(value) ⇒ Boolean
- #show_actions? ⇒ Boolean
- #show_job_actions ⇒ Object
- #update_state(state) ⇒ Object
Constructor Details
#initialize(job, batch_manager) ⇒ JobStatusDisplay
Returns a new instance of JobStatusDisplay
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/syskit/gui/job_status_display.rb', line 18 def initialize(job, batch_manager) super(nil) @batch_manager = batch_manager @job = job @exceptions = Array.new @notifications = Hash.new @show_actions = true create_ui connect_to_hooks hide_job_actions end |
Instance Attribute Details
#exceptions ⇒ Object (readonly)
Returns the value of attribute exceptions
12 13 14 |
# File 'lib/syskit/gui/job_status_display.rb', line 12 def exceptions @exceptions end |
#job ⇒ Object (readonly)
Returns the value of attribute job
5 6 7 |
# File 'lib/syskit/gui/job_status_display.rb', line 5 def job @job end |
#notifications ⇒ Object (readonly)
Returns the value of attribute notifications
13 14 15 |
# File 'lib/syskit/gui/job_status_display.rb', line 13 def notifications @notifications end |
#ui_drop ⇒ Object (readonly)
Returns the value of attribute ui_drop
10 11 12 |
# File 'lib/syskit/gui/job_status_display.rb', line 10 def ui_drop @ui_drop end |
#ui_job_actions ⇒ Object (readonly)
Returns the value of attribute ui_job_actions
7 8 9 |
# File 'lib/syskit/gui/job_status_display.rb', line 7 def ui_job_actions @ui_job_actions end |
#ui_notifications ⇒ Object (readonly)
Returns the value of attribute ui_notifications
14 15 16 |
# File 'lib/syskit/gui/job_status_display.rb', line 14 def ui_notifications @ui_notifications end |
#ui_restart ⇒ Object (readonly)
Returns the value of attribute ui_restart
9 10 11 |
# File 'lib/syskit/gui/job_status_display.rb', line 9 def ui_restart @ui_restart end |
#ui_start ⇒ Object (readonly)
Returns the value of attribute ui_start
8 9 10 |
# File 'lib/syskit/gui/job_status_display.rb', line 8 def ui_start @ui_start end |
#ui_state ⇒ Object (readonly)
Returns the value of attribute ui_state
11 12 13 |
# File 'lib/syskit/gui/job_status_display.rb', line 11 def ui_state @ui_state end |
Instance Method Details
#connect_to_hooks ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/syskit/gui/job_status_display.rb', line 134 def connect_to_hooks ui_drop.connect(SIGNAL('clicked()')) do @batch_manager.drop_job(self) if @actions_immediate @batch_manager.process end end ui_restart.connect(SIGNAL('clicked()')) do arguments = job.action_arguments.dup arguments.delete(:job_id) if @batch_manager.create_new_job(job.action_name, arguments) @batch_manager.drop_job(self) if @actions_immediate @batch_manager.process end end end ui_start.connect(SIGNAL('clicked()')) do arguments = job.action_arguments.dup arguments.delete(:job_id) if @batch_manager.create_new_job(job.action_name, arguments) if @actions_immediate @batch_manager.process end end end job.on_progress do |state| update_state(state) end job.on_exception do |kind, exception| exceptions << exception.exception notify('exceptions', "#{exceptions.size} exceptions") emit exceptionEvent end end |
#create_ui ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/syskit/gui/job_status_display.rb', line 42 def create_ui self.focus_policy = Qt::ClickFocus @ui_state = JobStateLabel.new name: label if job.state ui_state.update_state(job.state.upcase) end @ui_job_actions = Qt::Widget.new(self) hlayout = Qt::HBoxLayout.new(ui_job_actions) @actions_buttons = Hash[ 'Drop' => Qt::PushButton.new("Drop", self), 'Restart' => Qt::PushButton.new("Restart", self), "Start Again" => Qt::PushButton.new("Start Again", self) ] hlayout.(@ui_drop = @actions_buttons['Drop']) hlayout.(@ui_restart = @actions_buttons['Restart']) hlayout.(@ui_start = @actions_buttons['Start Again']) ui_start.hide hlayout.set_contents_margins(0, 0, 0, 0) @ui_notifications = Qt::Label.new("", self) ui_notifications.hide vlayout = Qt::VBoxLayout.new(self) vlayout. ui_state vlayout. ui_job_actions vlayout. ui_notifications end |
#enterEvent(event) ⇒ Object
110 111 112 113 114 115 116 |
# File 'lib/syskit/gui/job_status_display.rb', line 110 def enterEvent(event) super if show_actions? show_job_actions self.focus = Qt::OtherFocusReason end end |
#hide_job_actions ⇒ Object
102 103 104 105 106 107 |
# File 'lib/syskit/gui/job_status_display.rb', line 102 def hide_job_actions ui_job_actions.hide s = size s.height = size_hint.height self.size = s end |
#keyPressEvent(event) ⇒ Object
72 73 74 75 |
# File 'lib/syskit/gui/job_status_display.rb', line 72 def keyPressEvent(event) make_actions_immediate(event.key == Qt::Key_Control) super end |
#keyReleaseEvent(event) ⇒ Object
77 78 79 80 |
# File 'lib/syskit/gui/job_status_display.rb', line 77 def keyReleaseEvent(event) make_actions_immediate(false) super end |
#label ⇒ Object
38 39 40 |
# File 'lib/syskit/gui/job_status_display.rb', line 38 def label "##{job.job_id} #{job.action_name}" end |
#leaveEvent(event) ⇒ Object
118 119 120 121 122 123 |
# File 'lib/syskit/gui/job_status_display.rb', line 118 def leaveEvent(event) super if show_actions? hide_job_actions end end |
#make_actions_immediate(enable) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/syskit/gui/job_status_display.rb', line 82 def make_actions_immediate(enable) @actions_immediate = enable if enable @actions_buttons.each do |text, btn| btn.text = "#{text} Now" end else @actions_buttons.each do |text, btn| btn.text = text end end end |
#mousePressEvent(event) ⇒ Object
125 126 127 128 |
# File 'lib/syskit/gui/job_status_display.rb', line 125 def mousePressEvent(event) emit clicked event.accept end |
#mouseReleaseEvent(event) ⇒ Object
129 130 131 |
# File 'lib/syskit/gui/job_status_display.rb', line 129 def mouseReleaseEvent(event) event.accept end |
#notify(key, text) ⇒ Object
191 192 193 194 195 |
# File 'lib/syskit/gui/job_status_display.rb', line 191 def notify(key, text) notifications[key] = text ui_notifications.show ui_notifications.text = "<small>#{notifications.values.join(", ")}</small>" end |
#show_actions=(value) ⇒ Boolean
16 |
# File 'lib/syskit/gui/job_status_display.rb', line 16 attr_predicate :show_actions?, true |
#show_actions? ⇒ Boolean
16 |
# File 'lib/syskit/gui/job_status_display.rb', line 16 attr_predicate :show_actions?, true |
#show_job_actions ⇒ Object
95 96 97 98 99 100 |
# File 'lib/syskit/gui/job_status_display.rb', line 95 def show_job_actions ui_job_actions.show s = size s.height = size_hint.height self.size = s end |
#update_state(state) ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/syskit/gui/job_status_display.rb', line 170 def update_state(state) if INTERMEDIATE_TERMINAL_STATES.include?(ui_state.current_state) ui_state.update_state( "#{ui_state.current_state}, #{state.upcase}", color: ui_state.current_color) else ui_state.update_state(state.upcase) end if state == Roby::Interface::JOB_DROPPED ui_drop.hide ui_restart.hide ui_start.show elsif Roby::Interface.terminal_state?(state) ui_drop.hide ui_restart.hide ui_start.show end end |