Class: Syskit::GUI::BatchManager::NewJobDialog

Inherits:
Qt::Dialog
  • Object
show all
Defined in:
lib/syskit/gui/batch_manager.rb

Defined Under Namespace

Classes: Parser

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent = nil, text = '') ⇒ NewJobDialog

Returns a new instance of NewJobDialog



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/syskit/gui/batch_manager.rb', line 162

def initialize(parent = nil, text = '')
    super(parent)
    resize(800, 600)

    layout = Qt::VBoxLayout.new(self)
    @error_message = Qt::Label.new(self)
    @error_message.style_sheet = "QLabel { background-color: #ffb8b9; border: 1px solid #ff6567; padding: 5px; }"
    @error_message.frame_style = Qt::Frame::StyledPanel
    layout.add_widget(@error_message)
    @error_message.hide

    @editor = Qt::TextEdit.new(self)
    self.text = text
    layout.add_widget editor

    buttons = Qt::DialogButtonBox.new(Qt::DialogButtonBox::Ok | Qt::DialogButtonBox::Cancel)
    buttons.connect(SIGNAL('accepted()')) do
        begin
            @error_message.hide
            @result = Parser.parse(self.text)
            accept
        rescue Exception => e
            @error_message.text = e.message
            @error_message.show
        end
    end
    buttons.connect(SIGNAL('rejected()')) { reject }
    layout.add_widget buttons
end

Instance Attribute Details

#editorObject (readonly)

Returns the value of attribute editor



160
161
162
# File 'lib/syskit/gui/batch_manager.rb', line 160

def editor
  @editor
end

Class Method Details

.exec(parent, text) ⇒ Object



192
193
194
# File 'lib/syskit/gui/batch_manager.rb', line 192

def self.exec(parent, text)
    new(parent, text).exec
end

Instance Method Details

#resultObject



217
218
219
# File 'lib/syskit/gui/batch_manager.rb', line 217

def result
    @result
end

#textObject



225
226
227
# File 'lib/syskit/gui/batch_manager.rb', line 225

def text
    editor.to_plain_text
end

#text=(text) ⇒ Object



221
222
223
# File 'lib/syskit/gui/batch_manager.rb', line 221

def text=(text)
    editor.plain_text = text
end