def _make_buttonbox(self, **kwargs): # pytest: disable=unused-argument """ Make the gtk.ButtonBox() for the Similar Item class Work View. :return: _buttonbox; the gtk.ButtonBox() for the SimilarItem Work View. :rtype: :class:`gtk.ButtonBox` """ _tooltips = [ _(u"Edit the Similar Item analysis functions."), _(u"Roll up descriptions to next higher level assembly."), _(u"Calculate the Similar Item analysis."), _(u"Save the selected Similar Item analysis to the open RAMSTK " u"Program database."), _(u"Save all the Similar Item analyses for the selected Hardware " u"item to the open RAMSTK Program database.") ] _callbacks = [ self._do_request_edit_function, self._do_request_rollup, self._do_request_calculate, self._do_request_update, self._do_request_update_all ] _icons = ['edit', 'rollup', 'calculate', 'save', 'save-all'] _buttonbox = RAMSTKWorkView._make_buttonbox(self, icons=_icons, tooltips=_tooltips, callbacks=_callbacks, orientation='vertical', height=-1, width=-1) self._btn_rollup = _buttonbox.get_children()[1] return _buttonbox
def _make_buttonbox(self, **kwargs): # pylint: disable=unused-argument """ Create the gtk.ButtonBox() for the Revision Module View. :return: _buttonbox; the gtk.ButtonBox() for the Revision class Module View. :rtype: :class:`gtk.ButtonBox` """ _tooltips = [ _(u"Add a new Revision."), _(u"Remove the currently selected Revision."), _(u"Save the currently selected Revision to the open " u"RAMSTK Program database."), _(u"Saves all Revisions to the open RAMSTK Program " u"database.") ] _callbacks = [ self._do_request_insert_sibling, self._do_request_delete, self._do_request_update, self._do_request_update_all ] _icons = ['add', 'remove', 'save', 'save-all'] _buttonbox = RAMSTKModuleView._make_buttonbox(self, icons=_icons, tooltips=_tooltips, callbacks=_callbacks, orientation='vertical', height=-1, width=-1) return _buttonbox
def __init__(self, controller, **kwargs): """ Initialize the List View for the Stakeholder package. :param controller: the RAMSTK master data controller instance. :type controller: :class:`ramstk.RAMSTK.RAMSTK` """ RAMSTKListView.__init__(self, controller, module='stakeholder') # Initialize private dictionary attributes. # Initialize private list attributes. # Initialize private scalar attributes. self._revision_id = None self._stakeholder_id = None # Initialize public dictionary attributes. # Initialize public list attributes. # Initialize public scalar attributes. self._make_treeview() self.treeview.set_tooltip_text( _(u"Displays the list of stakeholder inputs for the selected " u"stakeholder.")) self._lst_handler_id.append( self.treeview.connect('cursor_changed', self._do_change_row)) self._lst_handler_id.append( self.treeview.connect('button_press_event', self._on_button_press)) # _icon = gtk.gdk.pixbuf_new_from_file_at_size(self._dic_icons['tab'], # 22, 22) # _image = gtk.Image() # _image.set_from_pixbuf(_icon) _label = gtk.Label() _label.set_markup("<span weight='bold'>" + _(u"Stakeholder\nInputs") + "</span>") _label.set_alignment(xalign=0.5, yalign=0.5) _label.set_justify(gtk.JUSTIFY_CENTER) _label.show_all() _label.set_tooltip_text( _(u"Displays stakeholder inputs for the " u"selected stakeholder.")) # self.hbx_tab_label.pack_start(_image) self.hbx_tab_label.pack_end(_label) self.hbx_tab_label.show_all() _scrolledwindow = gtk.ScrolledWindow() _scrolledwindow.add(self.treeview) self.pack_start(self._make_buttonbox(), expand=False, fill=False) self.pack_end(_scrolledwindow, expand=True, fill=True) self.show_all() pub.subscribe(self._on_select_revision, 'selectedRevision')
def _make_buttonbox(self, **kwargs): # pylin: disable=unused-argument """ Make the gtk.ButtonBox() for the Allocation class Work View. :return: _buttonbox; the gtk.ButtonBox() for the Allocation Work View. :rtype: :class:`gtk.ButtonBox` """ _tooltips = [ _(u"Calculate the currently selected child hardware item."), _(u"Save the currently selected line in the Allocation to the " u"open RAMSTK Program database."), _(u"Save the Allocation to the open RAMSTK Program database.") ] _callbacks = [ self._do_request_calculate, self._do_request_update, self._do_request_update_all ] _icons = ['calculate', 'save', 'save-all'] _buttonbox = RAMSTKWorkView._make_buttonbox(self, icons=_icons, tooltips=_tooltips, callbacks=_callbacks, orientation='vertical', height=-1, width=-1) return _buttonbox
def _make_buttonbox(self, **kwargs): """ Make the buttonbox for the Stakeholder List View. :return: _buttonbox; the gtk.ButtonBox() for the Stakeholder List View. :rtype: :class:`gtk.ButtonBox` """ _tooltips = [ _(u"Add a new Stakeholder."), _(u"Remove the currently selected Stakeholder."), _(u"Save the currently selected Stakeholder to " u"the open RAMSTK Program database."), _(u"Save all of the Stakeholders to the open RAMSTK " u"Program database."), _(u"Create the Stakeholder report.") ] _callbacks = [ self._do_request_insert_sibling, self._do_request_delete, self._do_request_update, self._do_request_update_all ] _icons = ['add', 'remove', 'save', 'save-all', 'reports'] _buttonbox = RAMSTKListView._make_buttonbox(self, icons=_icons, tooltips=_tooltips, callbacks=_callbacks, orientation='vertical', height=-1, width=-1) return _buttonbox
def _make_buttonbox(self, **kwargs): # pylint: disable=unused-argument """ Create the buttonbox for the Hardware:Requirement Matrix View. :return: _buttonbox; the gtk.ButtonBox() for the Hardware:Requirement Matrix View. :rtype: :class:`gtk.ButtonBox` """ _tooltips = [ _(u"Save the Hardware:Requirement Matrix to the open RAMSTK " u"Program database."), _(u"Create or refresh the Hardware:Requirement Matrix.") ] _callbacks = [self._do_request_update, self._do_request_create] _icons = ['save', 'view-refresh'] _buttonbox = ramstk.RAMSTKBaseMatrix._make_buttonbox( self, icons=_icons, tooltips=_tooltips, callbacks=_callbacks, orientation='vertical', height=-1, width=-1) return _buttonbox
def _do_request_delete(self, __button): """ Request to delete the selected record from the RAMSTKValidation table. :param __button: the gtk.ToolButton() that called this method. :type __button: :class:`gtk.ToolButton` :return: False if successful or True if an error is encountered. :rtype: bool """ _return = False _prompt = _(u"You are about to delete Validation {0:d} and all data " u"associated with it. Is this really what you want " u"to do?").format(self._validation_id) _dialog = ramstk.RAMSTKMessageDialog(_prompt, self._dic_icons['question'], 'question') _response = _dialog.do_run() if _response == gtk.RESPONSE_YES: _dialog.do_destroy() if self._dtc_function.request_do_delete(self._function_id): _prompt = _(u"An error occurred when attempting to delete " u"Validation {0:d}.").format(self._validation_id) _error_dialog = ramstk.RAMSTKMessageDialog( _prompt, self._dic_icons['error'], 'error') if _error_dialog.do_run() == gtk.RESPONSE_OK: _error_dialog.do_destroy() _return = True else: _dialog.do_destroy() return _return
def _make_buttonbox(self, **kwargs): # pylint: disable=unused-argument """ Create the gtk.ButtonBox() for the Validation Module View. :return: _buttonbox; the gtk.ButtonBox() for the Validation class Module View. :rtype: :class:`gtk.ButtonBox` """ _tooltips = [ _(u"Add a new Validation task."), _(u"Remove the currently selected Validation task1."), _(u"Save the currently selected Validation task to the open " u"RAMSTK Program database."), _(u"Saves all Validation tasks to the open RAMSTK Program " u"database."), _(u"Exports Verification tasks to an external file (CSV, Excel, " u"and text files are supported).") ] _callbacks = [ self._do_request_insert_sibling, self._do_request_delete, self._do_request_update, self._do_request_update_all, self._do_request_export ] _icons = ['add', 'remove', 'save', 'save-all', 'export'] _buttonbox = RAMSTKModuleView._make_buttonbox(self, icons=_icons, tooltips=_tooltips, callbacks=_callbacks, orientation='vertical', height=-1, width=-1) return _buttonbox
def _make_buttonbox(self, **kwargs): # pylint: disable=unused-argument """ Create the Revision Work View gtk.ButtonBox(). :return: _buttonbox; the gtk.ButtonBox() for the Revision class Work View. :rtype: :py:class:`gtk.ButtonBox` """ _tooltips = [ _(u"Saves the currently selected Revision to the open " u"RAMSTK Program database."), _(u"Save all Revisions to the open RAMSTK Program database.") ] _callbacks = [self._do_request_update, self._do_request_update_all] _icons = ['save', 'save-all'] _buttonbox = RAMSTKWorkView._make_buttonbox(self, icons=_icons, tooltips=_tooltips, callbacks=_callbacks, orientation='vertical', height=-1, width=-1) return _buttonbox
def _make_page(self): """ Create the Revision Work View general data page. :return: False if successful or True if an error is encountered. :rtype: bool """ _fixed = gtk.Fixed() _scrollwindow = ramstk.RAMSTKScrolledWindow(_fixed) _frame = ramstk.RAMSTKFrame(label=_(u"General Information")) _frame.add(_scrollwindow) _x_pos, _y_pos = ramstk.make_label_group(self._lst_gendata_labels, _fixed, 5, 5) _x_pos += 50 _fixed.put(self.txtCode, _x_pos, _y_pos[0]) _fixed.put(self.txtName, _x_pos, _y_pos[1]) _fixed.put(self.txtRemarks.scrollwindow, _x_pos, _y_pos[2]) _fixed.show_all() _label = ramstk.RAMSTKLabel( _(u"General\nData"), height=30, width=-1, justify=gtk.JUSTIFY_CENTER, tooltip=_(u"Displays general information for the selected " u"revision.")) self.hbx_tab_label.pack_start(_label) return _frame
def __init__(self, controller, **kwargs): # pylint: disable=unused-argument """ Initialize the Module View for the Hardware package. :param controller: the RAMSTK Master data controller instance. :type controller: :class:`ramstk.RAMSTK.RAMSTK` """ RAMSTKModuleView.__init__(self, controller, module='hardware') # Initialize private dictionary attributes. self._dic_icons['tab'] = controller.RAMSTK_CONFIGURATION.RAMSTK_ICON_DIR + \ '/32x32/hardware.png' self._dic_icons['insert_part'] = \ controller.RAMSTK_CONFIGURATION.RAMSTK_ICON_DIR + \ '/32x32/insert_part.png' # Initialize private list attributes. # Initialize private scalar attributes. self._hardware_id = None self._revision_id = None # Initialize public dictionary attributes. # Initialize public list attributes. # Initialize public scalar attributes. self._make_treeview() self.treeview.set_tooltip_text( _(u"Displays the hierarchical list of " u"hardware items.")) self._lst_handler_id.append( self.treeview.connect('cursor_changed', self._do_change_row)) self._lst_handler_id.append( self.treeview.connect('button_press_event', self._on_button_press)) self._img_tab.set_from_file(self._dic_icons['tab']) _label = ramstk.RAMSTKLabel( _(u"Hardware"), width=-1, height=-1, tooltip=_(u"Displays the hierarchical list of hardware items.")) self.hbx_tab_label.pack_start(self._img_tab) self.hbx_tab_label.pack_end(_label) self.hbx_tab_label.show_all() _scrollwindow = gtk.ScrolledWindow() _scrollwindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) _scrollwindow.add_with_viewport(self._make_buttonbox()) self.pack_start(_scrollwindow, expand=False, fill=False) self.show_all() pub.subscribe(self._on_select_revision, 'selectedRevision') pub.subscribe(self._on_edit, 'wvwEditedHardware') pub.subscribe(self._on_calculate, 'calculatedAllHardware')
def __init__(self, controller, **kwargs): """ Initialize an instance of the Switch assessment input view. :param controller: the hardware data controller instance. :type controller: :class:`ramstk.hardware.Controller.HardwareBoMDataController` """ AssessmentInputs.__init__(self, controller, **kwargs) # Initialize private dictionary attributes. # Initialize private list attributes. self._lst_labels.append(_(u"Application:")) self._lst_labels.append(_(u"Construction:")) self._lst_labels.append(_(u"Contact Form:")) self._lst_labels.append(_(u"Number of Cycles/Hour:")) self._lst_labels.append(_(u"Number of Active Contacts:")) # Initialize private scalar attributes. # Initialize public dictionary attributes. # Initialize public list attributes. # Initialize public scalar attributes. self.cmbApplication = ramstk.RAMSTKComboBox( index=0, simple=True, tooltip=_(u"The application of the switch.")) self.cmbConstruction = ramstk.RAMSTKComboBox( index=0, simple=False, tooltip=_(u"The construction method for " u"the switch.")) self.cmbContactForm = ramstk.RAMSTKComboBox( index=0, simple=True, tooltip=_(u"The contact form and quantity of the switch.")) self.txtNCycles = ramstk.RAMSTKEntry( width=125, tooltip=_(u"The number of cycles per hour of the switch.")) self.txtNElements = ramstk.RAMSTKEntry( width=125, tooltip=_(u"The number of active contacts in the switch.")) self._make_page() self.show_all() self._lst_handler_id.append( self.cmbQuality.connect('changed', self._on_combo_changed, 0)) self._lst_handler_id.append( self.cmbApplication.connect('changed', self._on_combo_changed, 1)) self._lst_handler_id.append( self.cmbConstruction.connect('changed', self._on_combo_changed, 2)) self._lst_handler_id.append( self.cmbContactForm.connect('changed', self._on_combo_changed, 3)) self._lst_handler_id.append( self.txtNCycles.connect('changed', self._on_focus_out, 4)) self._lst_handler_id.append( self.txtNElements.connect('changed', self._on_focus_out, 5))
def _do_load_comboboxes(self, **kwargs): """ Load the Resisotr RKTComboBox()s. :param int subcategory_id: the newly selected resistor subcategory ID. :return: False if successful or True if an error is encountered. :rtype: bool """ _return = False _attributes = AssessmentInputs.do_load_comboboxes(self, **kwargs) # Load the quality level RAMSTKComboBox(). if _attributes['hazard_rate_method_id'] == 1: _data = ["S", "R", "P", "M", ["MIL-SPEC"], [_(u"Lower")]] else: try: _data = self._dic_quality[self._subcategory_id] except KeyError: _data = [] self.cmbQuality.do_load_combo(_data) # Load the specification RAMSTKComboBox(). try: _data = self._dic_specifications[self._subcategory_id] except KeyError: _data = [] self.cmbSpecification.do_load_combo(_data) # Load the type RAMSTKComboBox(). if _attributes['hazard_rate_method_id'] == 1: try: _data = self._dic_types[self._subcategory_id] except KeyError: _data = [] else: _data = [[_(u"Bead")], [_(u"Disk")], [_(u"Rod")]] self.cmbType.do_load_combo(_data) # Load the style RAMSTKComboBox(). try: _data = self._dic_styles[_attributes['subcategory_id']][ _attributes['specification_id']] except (KeyError, IndexError): _data = [] self.cmbStyle.do_load_combo(_data) # Load the construction RAMSTKComboBox(). try: _data = self._dic_construction[self._subcategory_id] except KeyError: _data = [] self.cmbConstruction.do_load_combo(_data) return _return
def __init__(self, controller, **kwargs): # pylint: disable=unused-argument """ Initialize the List View for the Failure Definition package. :param controller: the RAMSTK master data controller instance. :type controller: :class:`ramstk.RAMSTK.RAMSTK` """ RAMSTKListView.__init__(self, controller, module='failure_definition') # Initialize private dictionary attributes. # Initialize private list attributes. # Initialize private scalar attributes. self._revision_id = None self._definition_id = None # Initialize public dictionary attributes. # Initialize public list attributes. # Initialize public scalar attributes. self._make_treeview() self.treeview.set_rubber_banding(True) self.treeview.set_tooltip_text( _(u"Displays the list of failure definitions for the selected " u"revision.")) self._lst_handler_id.append( self.treeview.connect('cursor_changed', self._do_change_row)) self._lst_handler_id.append( self.treeview.connect('button_press_event', self._on_button_press)) _label = gtk.Label() _label.set_markup("<span weight='bold'>" + _(u"Failure\nDefinitions") + "</span>") _label.set_alignment(xalign=0.5, yalign=0.5) _label.set_justify(gtk.JUSTIFY_CENTER) _label.show_all() _label.set_tooltip_text( _(u"Displays failure definitions for the " u"selected revision.")) self.hbx_tab_label.pack_end(_label) self.hbx_tab_label.show_all() _scrolledwindow = gtk.ScrolledWindow() _scrolledwindow.add(self.treeview) self.pack_start(self._make_buttonbox(), expand=False, fill=False) self.pack_end(_scrolledwindow, expand=True, fill=True) self.show_all() pub.subscribe(self._on_select_revision, 'selectedRevision')
def __init__(self, controller, **kwargs): """ Initialize an instance of the Relay assessment result view. :param controller: the hardware data controller instance. :type controller: :class:`ramstk.hardware.Controller.HardwareBoMDataController` """ AssessmentResults.__init__(self, controller, **kwargs) # Initialize private dictionary attributes. # Initialize private list attributes. self._lst_labels.append(u"\u03C0<sub>C</sub>:") self._lst_labels.append(u"\u03C0<sub>CYC</sub>:") self._lst_labels.append(u"\u03C0<sub>F</sub>:") self._lst_labels.append(u"\u03C0<sub>L</sub>:") # Initialize private scalar attributes. self._lblModel.set_tooltip_markup( _(u"The assessment model used to calculate the relay's failure " u"rate.")) # Initialize public dictionary attributes. # Initialize public list attributes. # Initialize public scalar attributes. self.txtPiC = ramstk.RAMSTKEntry( width=125, editable=False, bold=True, tooltip=_(u"The contact form factor for the relay.")) self.txtPiCYC = ramstk.RAMSTKEntry( width=125, editable=False, bold=True, tooltip=_(u"The cycling factor for the relay.")) self.txtPiF = ramstk.RAMSTKEntry( width=125, editable=False, bold=True, tooltip=_(u"The application and construction factor for the " u"relay.")) self.txtPiL = ramstk.RAMSTKEntry( width=125, editable=False, bold=True, tooltip=_(u"The load stress factor for the relay.")) self._make_page() self.show_all() pub.subscribe(self._do_load_page, 'calculatedHardware')
def __init__(self, controller, **kwargs): """ Initialize an instance of the Hardware assessment result view. :param controller: the hardware data controller instance. :type controller: :class:`ramstk.hardware.Controller.HardwareBoMDataController` :param int hardware_id: the hardware ID of the currently selected hardware item. :param int subcategory_id: the ID of the hardware item subcategory. """ gtk.Fixed.__init__(self) # Initialize private dictionary attributes. # Initialize private list attributes. self._lst_labels = [ u"\u03BB<sub>b</sub>:", u"\u03C0<sub>Q</sub>:", u"\u03C0<sub>E</sub>:" ] # Initialize private scalar attributes. self._dtc_data_controller = controller self._hardware_id = kwargs['hardware_id'] self._subcategory_id = kwargs['subcategory_id'] self._lblModel = ramstk.RAMSTKLabel( '', tooltip=_(u"The assessment model used to calculate the hardware " u"item failure rate.")) # Initialize public dictionary attributes. # Initialize public list attributes. # Initialize public scalar attributes. self.fmt = None self.txtLambdaB = ramstk.RAMSTKEntry( width=125, editable=False, bold=True, tooltip=_(u"The base hazard rate of the hardware item.")) self.txtPiQ = ramstk.RAMSTKEntry( width=125, editable=False, bold=True, tooltip=_(u"The quality factor for the hardware item.")) self.txtPiE = ramstk.RAMSTKEntry( width=125, editable=False, bold=True, tooltip=_(u"The environment factor for the hardware item."))
def _make_buttonbox(self, **kwargs): # pylint: disable=unused-argument """ Make the gtk.ButtonBox() for the Hardware class Module View. :return: _buttonbox; the gtk.ButtonBox() for the Hardware class Module View. :rtype: :class:`gtk.ButtonBox` """ _tooltips = [ _(u"Adds a new Hardware assembly at the same hierarchy level as " u"the selected Hardware (i.e., a sibling Hardware)."), _(u"Adds a new Hardware assembly one level subordinate to the " u"selected Hardware (i.e., a child hardware)."), _(u"Adds a new Hardware component/piece-part at the same " u"hierarchy level as the selected Hardware component/piece-part " u"(i.e., a sibling component/piece-part)."), _(u"Adds a new Hardware component/piece-part one level " u"subordinate to selected Hardware component/piece-part " u"(i.e., a child component/piece-part)."), _(u"Remove the currently selected Hardware item and any " u"children."), _(u"Calculate the entire system."), _(u"Save the currently selected Hardware item to the open " u"RAMSTK Program database."), _(u"Saves all Hardware items to the open RAMSTK Program " u"database."), _(u"Exports Hardware to an external file (CSV, Excel, and text " u"files are supported).") ] _callbacks = [ self._do_request_insert_sibling, self._do_request_insert_child, self._do_request_insert_sibling, self._do_request_insert_child, self._do_request_delete, self._do_request_calculate_all, self._do_request_update, self._do_request_update_all, self._do_request_export ] _icons = [ 'insert_sibling', 'insert_child', 'insert_part', 'insert_part', 'remove', 'calculate_all', 'save', 'save-all', 'export' ] _buttonbox = RAMSTKModuleView._make_buttonbox( self, icons=_icons, tooltips=_tooltips, callbacks=_callbacks, orientation='vertical', height=-1, width=-1) _buttons = _buttonbox.get_children() _buttons[0].set_property('name', 'assembly') _buttons[1].set_property('name', 'assembly') _buttons[2].set_property('name', 'part') _buttons[3].set_property('name', 'part') return _buttonbox
def _make_map_field_page(self): """ Make the Import Assistant page to map fields. This method allows the user to map input file fields to RAMSTK database table fields. :return: _page :rtype: :class:`gtk.ScrolledWindow` """ _page = gtk.ScrolledWindow() _page.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) _page.add(self._tvw_field_map) _model = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING) _column = gtk.TreeViewColumn() _label = ramstk.RAMSTKLabel( _(u"Import File Column"), justify=gtk.JUSTIFY_CENTER) _column.set_widget(_label) _cell = gtk.CellRendererText() _cell.set_property('foreground', '#000000') _cell.set_property('cell-background', 'light gray') _column.pack_start(_cell, True) _column.set_attributes(_cell, text=0) _column.set_visible(True) self._tvw_field_map.append_column(_column) _column = gtk.TreeViewColumn() _label = ramstk.RAMSTKLabel( _(u"RAMSTK Field"), justify=gtk.JUSTIFY_CENTER) _column.set_widget(_label) _cell = gtk.CellRendererCombo() _cellmodel = gtk.ListStore(gobject.TYPE_STRING) _cellmodel.append([""]) _cell.set_property('editable', True) _cell.set_property('foreground', '#000000') _cell.set_property('has-entry', False) _cell.set_property('model', _cellmodel) _cell.set_property('text-column', 0) _cell.connect('edited', self._do_edit_cell, _model) _column.pack_start(_cell, True) _column.set_attributes(_cell, text=1) _column.set_visible(True) self._tvw_field_map.append_column(_column) self._tvw_field_map.set_model(_model) return _page
def __init__(self, controller, **kwargs): # pylint: disable=unused-argument """ Initialize the Work View for the Function package. :param controller: the RAMSTK master data controller instance. :type controller: :class:`ramstk.RAMSTK.RAMSTK` """ RAMSTKWorkView.__init__(self, controller, module='Function') # Initialize private dictionary attributes. # Initialize private list attributes. self._lst_gendata_labels = [ _(u"Function Code:"), _(u"Function Description:"), _(u"Remarks:") ] # Initialize private scalar attributes. self._function_id = None # Initialize public dictionary attributes. # Initialize public list attributes. # Initialize public scalar attributes. # General data page widgets. self.chkSafetyCritical = ramstk.RAMSTKCheckButton( label=_(u"Function is safety critical."), tooltip=_(u"Indicates whether or not the selected function is " u"safety critical.")) self.txtCode = ramstk.RAMSTKEntry( width=125, tooltip=_(u"A unique code for the selected function.")) self.txtName = ramstk.RAMSTKEntry( width=800, tooltip=_(u"The name of the selected function.")) self.txtRemarks = ramstk.RAMSTKTextView( gtk.TextBuffer(), width=800, tooltip=_(u"Enter any remarks associated with the " u"selected function.")) # Connect to callback functions for editable gtk.Widgets(). self._lst_handler_id.append( self.txtCode.connect('changed', self._on_focus_out, 0)) self._lst_handler_id.append( self.txtName.connect('changed', self._on_focus_out, 1)) self._lst_handler_id.append(self.txtRemarks.do_get_buffer().connect( 'changed', self._on_focus_out, 2)) self._lst_handler_id.append( self.chkSafetyCritical.connect('toggled', self._on_toggled, 3)) self.pack_start(self._make_buttonbox(), expand=False, fill=False) self.pack_start(self._make_page(), expand=True, fill=True) self.show_all() # Subscribe to PyPubSub messages. pub.subscribe(self._do_load_page, 'selected_function') pub.subscribe(self._do_clear_page, 'closed_program')
def __init__(self, controller, **kwargs): """ Initialize the Hardware:Requirement Matrix View. :param controller: the RAMSTK master data controller instance. :type controller: :py:class:`ramstk.RAMSTK.RAMSTK` """ gtk.HBox.__init__(self) ramstk.RAMSTKBaseMatrix.__init__(self, controller, **kwargs) # Initialize private dictionary attributes. # Initialize private list attributes. # Initialize private scalar attributes. self._dtc_data_controller = None self._revision_id = None self._matrix_type = kwargs['matrix_type'] # Initialize public dictionary attributes. # Initialize public list attributes. # Initialize public scalar attributes. self.hbx_tab_label = gtk.HBox() _label = gtk.Label() _label.set_markup("<span weight='bold'>" + _(u"Hardware\nRequirement") + "</span>") _label.set_alignment(xalign=0.5, yalign=0.5) _label.set_justify(gtk.JUSTIFY_CENTER) _label.show_all() _label.set_tooltip_text( _(u"Displays hardware/requirement matrix for the " u"selected revision.")) # self.hbx_tab_label.pack_start(_image) self.hbx_tab_label.pack_end(_label) self.hbx_tab_label.show_all() _scrolledwindow = gtk.ScrolledWindow() _scrolledwindow.add(self.matrix) self.pack_start(self._make_buttonbox(), expand=False, fill=False) self.pack_end(_scrolledwindow, expand=True, fill=True) self.show_all() pub.subscribe(self._on_select_revision, 'selectedRevision')
def _on_select(self, module_id, **kwargs): """ Respond to the `selectedHardware` signal from pypubsub. :param int module_id: the ID of the Hardware that was selected. :return: None :rtype: None """ self._parent_id = module_id # pylint: disable=attribute-defined-outside-init # It is defined in RAMSTKBaseView.__init__ if self._dtc_data_controller is None: self._dtc_data_controller = self._mdcRAMSTK.dic_controllers[ 'similaritem'] if self._dtc_hw_controller is None: self._dtc_hw_controller = self._mdcRAMSTK.dic_controllers[ 'hardware'] (_error_code, _user_msg, _debug_msg) = self._do_load_page(**kwargs) RAMSTKWorkView.on_select(self, title=_( u"Similar Item Analysis for Hardware ID " u"{0:d}").format(self._parent_id), error_code=_error_code, user_msg=_user_msg, debug_msg=_debug_msg) return None
def _on_select_revision(self, module_id): """ Load the Validation Module View RAMSTKTreeView(). This method loads the RAMSTKTreeView() with Validation attribute data when an RAMSTK Program database is opened. :return: False if successful or True if an error is encountered. :rtype: bool """ self._revision_id = module_id # pylint: disable=attribute-defined-outside-init # It is defined in RAMSTKBaseView.__init__ self._dtc_data_controller = self._mdcRAMSTK.dic_controllers[ 'validation'] _validations = self._dtc_data_controller.request_do_select_all( revision_id=self._revision_id) _return = RAMSTKModuleView.on_select_revision(self, tree=_validations) if _return: _prompt = _(u"An error occured while loading Validation Tasks " u"into the Module View.") _dialog = ramstk.RAMSTKMessageDialog(_prompt, self._dic_icons['error'], 'error') if _dialog.do_run() == self._response_ok: _dialog.do_destroy() return _return
def _do_request_insert(self, **kwargs): # pylint: disable=unused-argument """ Send request to insert a new record to the RAMSTKValidation table. :param __button: the gtk.ToolButton() that called this method. :type __button: :class:`gtk.ToolButton` :return: False if successful or True if an error is encountered. :rtype: bool """ _return = False self._dtc_data_controller.request_do_select(self._validation_id) if not self._dtc_data_controller.request_do_insert(): self._on_select_validation() else: _prompt = _(u"An error occurred while attempting to add a " u"Validation.") _error_dialog = ramstk.RAMSTKMessageDialog( _prompt, self._dic_icons['error'], 'error') self._mdcRAMSTK.debug_log.error(_prompt) if _error_dialog.do_run() == gtk.RESPONSE_OK: _error_dialog.do_destroy() _return = True return _return
def _make_page(self): """ Make the Similar Item RAMSTKTreeview(). :return: a gtk.Frame() containing the instance of gtk.Treeview(). :rtype: :class:`gtk.Frame` """ # Load the quality from and quality to gtk.CellRendererCombo(). for _idx in [4, 5]: _model = self._get_cell_model(_idx) for _quality in self._dic_quality: _model.append([ _quality, ]) # Load the environment from and environment to gtk.CellRendererCombo(). for _idx in [6, 7]: _model = self._get_cell_model(_idx) for _environment in self._dic_environment: _model.append([ _environment, ]) _scrollwindow = gtk.ScrolledWindow() _scrollwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) _scrollwindow.add(self.treeview) _frame = ramstk.RAMSTKFrame(label=_(u"Similar Item Analysis")) _frame.set_shadow_type(gtk.SHADOW_ETCHED_OUT) _frame.add(_scrollwindow) self.treeview.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH) return _frame
def _on_select_revision(self, module_id): """ Load the Requirement Module View gtk.TreeModel(). This method is called whenever an RAMSTK Program database is opened or a Revision is selected in the Module Book. :return: False if successful or True if an error is encountered. :rtype: bool """ self._revision_id = module_id # pylint: disable=attribute-defined-outside-init # It is defined in RAMSTKBaseView.__init__ if self._dtc_data_controller is None: self._dtc_data_controller = self._mdcRAMSTK.dic_controllers[ 'requirement'] _requirements = self._dtc_data_controller.request_do_select_all( revision_id=self._revision_id) _return = RAMSTKModuleView.on_select_revision(self, tree=_requirements) if _return: _prompt = _(u"An error occured while loading the Requirements for " u"Revision ID {0:d} into the Module " u"View.").format(self._revision_id) _dialog = ramstk.RAMSTKMessageDialog(_prompt, self._dic_icons['error'], 'error') if _dialog.do_run() == self._response_ok: _dialog.do_destroy() return _return
def request_do_save_program(self): """ Request the open RAMSTK Program database be saved. :return: False if successful or True if an error is encountered. :rtype: bool """ _return = False # TODO: Move this to the ModuleBook. _message = _(u"Saving Program Database {0:s}"). \ format(self.RAMSTK_CONFIGURATION.RAMSTK_PROG_INFO['database']) self.dic_books['modulebook'].statusbar.push(2, _message) _error_code, _msg = self.ramstk_model.do_save_program() if _error_code == 0: self.RAMSTK_CONFIGURATION.RAMSTK_USER_LOG.info(_msg) if not self.__test: pub.sendMessage('savedProgram') else: self.RAMSTK_CONFIGURATION.RAMSTK_DEBUG_LOG.error(_msg) _return = True # TODO: Move this to the ModuleBook. self.dic_books['modulebook'].statusbar.pop(2) return _return
def _on_select(self, module_id, **kwargs): # pylint: disable=unused-argument """ Respond to `selectedHardware` signal from pypubsub. :param int module_id: the ID Of the Hardware item that was selected. :return: None :rtype: None """ self._hardware_id = module_id _model = self.treeview.get_model() _model.clear() # pylint: disable=attribute-defined-outside-init # It is defined in RAMSTKBaseView.__init__ if self._dtc_data_controller is None: self._dtc_data_controller = self._mdcRAMSTK.dic_controllers['pof'] _pof = self._dtc_data_controller.request_do_select_all( parent_id=self._hardware_id, functional=False) (_error_code, _user_msg, _debug_msg) = self._do_load_page( tree=_pof, row=None) RAMSTKWorkView.on_select( self, title=_(u"Analyzing Physics of Failure for Hardware ID " u"{0:d}").format(self._hardware_id), error_code=_error_code, user_msg=_user_msg, debug_msg=_debug_msg) return None
def _do_request_update_all(self, __button): """ Save all the Stakeholder Inputs. :param __button: the gtk.ToolButton() that called this method. :type __button: :class:`gtk.ToolButton` :return: False if successful or True if an error is encountered. :rtype: bool """ _return = False self.set_cursor(gtk.gdk.WATCH) if not self._dtc_data_controller.request_do_update_all(): self._on_select_revision(self._revision_id) else: _prompt = _(u"An error occurred attempting to save the " u"stakeholder inputs for Stakeholder {0:d}.").\ format(self._stakeholder_id) ramstk.RAMSTKMessageDialog(_prompt, self._dic_icons['error'], 'error') _return = True self.set_cursor(gtk.gdk.LEFT_PTR) return _return
def _on_select_revision(self, module_id): """ Load the Hardware Module View RAMSTKTreeView(). This method is called whenever an RAMSTK Program database is opened. :return: False if successful or True if an error is encountered. :rtype: bool """ self._revision_id = module_id # pylint: disable=attribute-defined-outside-init # It is defined in RAMSTKBaseView.__init__ self._dtc_data_controller = self._mdcRAMSTK.dic_controllers['hardware'] _hardware = self._dtc_data_controller.request_do_select_all( revision_id=self._revision_id) _return = RAMSTKModuleView.on_select_revision(self, tree=_hardware) if _return: _prompt = _(u"An error occured while loading the Hardware for " u"Revision ID {0:d} into the Module " u"View.").format(self._revision_id) _dialog = ramstk.RAMSTKMessageDialog( _prompt, self._dic_icons['error'], 'error') if _dialog.do_run() == self._response_ok: _dialog.do_destroy() else: for _analysis in ['allocation', 'hazops', 'similaritem']: _dtc_data_controller = self._mdcRAMSTK.dic_controllers[ _analysis] _dtc_data_controller.request_do_select_all( revision_id=self._revision_id) return _return
def _do_request_delete(self, __button): """ Request to delete the selected Stakeholder. :param __button: the gtk.ToolButton() that called this method. :type __button: :class:`gtk.ToolButton` :return: False if successful or True if an error is encountered. :rtype: bool """ _return = False _model, _row = self.treeview.get_selection().get_selected() _stakeholder_id = _model.get_value(_row, 0) if not self._dtc_data_controller.request_do_delete(_stakeholder_id): self._on_select_revision(module_id=self._revision_id) else: _prompt = _(u"An error occurred attempting to delete failure " u"stakeholder {0:d} to Stakeholder {1:d}.").\ format(_stakeholder_id, self._stakeholder_id) ramstk.RAMSTKMessageDialog(_prompt, self._dic_icons['error'], 'error') _return = True return _return