From 687bdbe69f4ce45f68e71b0b14f22a8f59ac92fd Mon Sep 17 00:00:00 2001 From: Doyle Rowland Date: Sat, 14 Jul 2018 12:46:04 -0400 Subject: [PATCH] Create ability to close open database without closing RTK. - Fixes issue #21. - Create new methods to clear GUI widgets in response to 'closedProgram' PyPubSub signal. Signed-off-by: Doyle Rowland --- src/rtk/RTK.py | 11 +- src/rtk/dao/DAO.py | 5 + src/rtk/gui/gtk/mwi/ListBook.py | 24 +++ src/rtk/gui/gtk/mwi/ModuleBook.py | 20 +- src/rtk/gui/gtk/mwi/WorkBook.py | 10 +- src/rtk/gui/gtk/workviews/Allocation.py | 32 ++- src/rtk/gui/gtk/workviews/FMEA.py | 39 ++++ src/rtk/gui/gtk/workviews/Function.py | 24 +++ src/rtk/gui/gtk/workviews/Hardware.py | 235 +++++++++++++++++++++++ src/rtk/gui/gtk/workviews/HazOps.py | 17 ++ src/rtk/gui/gtk/workviews/PoF.py | 17 ++ src/rtk/gui/gtk/workviews/Requirement.py | 75 ++++++++ src/rtk/gui/gtk/workviews/Revision.py | 41 ++-- src/rtk/gui/gtk/workviews/SimilarItem.py | 21 ++ src/rtk/gui/gtk/workviews/Validation.py | 102 ++++++++++ 15 files changed, 644 insertions(+), 29 deletions(-) diff --git a/src/rtk/RTK.py b/src/rtk/RTK.py index 9cf580c26..2d735aca3 100644 --- a/src/rtk/RTK.py +++ b/src/rtk/RTK.py @@ -231,10 +231,10 @@ def open_program(self, database): return _error_code, _msg - def close_program(self): + def do_close_program(self): """Close the open RTK Program database.""" self.program_dao.db_close() - + print self.program_dao.engine, self.program_dao.session, self.program_dao.metadata, self.program_dao.database return None def save_program(self): @@ -777,7 +777,7 @@ def request_open_program(self): return _return - def request_close_program(self): + def request_do_close_program(self): """ Request the open RTK Program database be closed. @@ -795,7 +795,10 @@ def request_close_program(self): if not self.__test: pub.sendMessage('closedProgram') - return self.rtk_model.close_program() + if not self.rtk_model.do_close_program(): + self.loaded = False + + return self.loaded def request_save_program(self): """ diff --git a/src/rtk/dao/DAO.py b/src/rtk/dao/DAO.py index 4c045e38a..033d95560 100644 --- a/src/rtk/dao/DAO.py +++ b/src/rtk/dao/DAO.py @@ -11,6 +11,7 @@ from sqlalchemy import create_engine, exc, MetaData from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker +from sqlalchemy.pool import NullPool # Import tables objects for the RTK Common database. from .RTKCommonDB import create_common_db @@ -81,8 +82,12 @@ def db_close(self): :rtype: bool """ self.session.close() + self.RTK_SESSION.close_all() self.engine.dispose() + self.session = None + self.engine = None self.metadata = None + self.database = None return False diff --git a/src/rtk/gui/gtk/mwi/ListBook.py b/src/rtk/gui/gtk/mwi/ListBook.py index f693e7cb4..225d7127c 100644 --- a/src/rtk/gui/gtk/mwi/ListBook.py +++ b/src/rtk/gui/gtk/mwi/ListBook.py @@ -100,6 +100,30 @@ def __init__(self, controller): self.show_all() pub.subscribe(self._on_module_change, 'mvwSwitchedPage') + pub.subscribe(self._on_close, 'closedProgram') + + def _on_close(self): + """ + Update the Modules Views when a RTK Program database is closed. + + :return: None + :rtype: None + """ + for _key in self.dic_list_view: + for _listview in self.dic_list_view[_key]: + try: + _view = _listview.treeview + except AttributeError: + _view = _listview.matrix + + _model = _view.get_model() + _columns = _view.get_columns() + for _column in _columns: + _view.remove_column(_column) + + _model.clear() + + return None def _on_module_change(self, module=''): """ diff --git a/src/rtk/gui/gtk/mwi/ModuleBook.py b/src/rtk/gui/gtk/mwi/ModuleBook.py index b9c5d6655..2bb40b3f4 100644 --- a/src/rtk/gui/gtk/mwi/ModuleBook.py +++ b/src/rtk/gui/gtk/mwi/ModuleBook.py @@ -142,6 +142,7 @@ def __init__(self, controller): pub.subscribe(self._on_request_open, 'requestOpen') pub.subscribe(self._on_open, 'openedProgram') + pub.subscribe(self._on_close, 'closedProgram') def _make_menu(self): """ @@ -177,7 +178,7 @@ def _make_menu(self): _menu.append(_menu_item) _menu_item = gtk.MenuItem(label=_(u"_Close"), use_underline=True) - _menu_item.connect('activate', self._request_close_project) + _menu_item.connect('activate', self._do_request_close_project) _menu.append(_menu_item) _menu_item = gtk.ImageMenuItem() @@ -401,6 +402,19 @@ def _on_request_open(self): return _return + def _on_close(self): + """ + Update the Modules Views when a RTK Program database is closed. + + :return: None + :rtype: None + """ + for _moduleview in self._lst_module_views: + _model = _moduleview[0].treeview.get_model() + _model.clear() + + return None + def _on_open(self): """ Update the status bar and clear the progress bar. @@ -492,7 +506,7 @@ def _request_save_project(self, __widget, end=False): return False - def _request_close_project(self, __widget): + def _do_request_close_project(self, __widget): """ Request to close the open RTK Program. @@ -500,6 +514,6 @@ def _request_close_project(self, __widget): :return: False if successful or True if an error is encountered. :rtype: bool """ - self._mdcRTK.close_project() + self._mdcRTK.request_do_close_program() return False diff --git a/src/rtk/gui/gtk/mwi/WorkBook.py b/src/rtk/gui/gtk/mwi/WorkBook.py index a7cfb3b10..dc8d15a81 100644 --- a/src/rtk/gui/gtk/mwi/WorkBook.py +++ b/src/rtk/gui/gtk/mwi/WorkBook.py @@ -16,8 +16,8 @@ from rtk.gui.gtk.workviews import wvwHazOps from rtk.gui.gtk.workviews import wvwPoF from rtk.gui.gtk.workviews import wvwSimilarItem -from rtk.gui.gtk.workviews import wvwFunctionGD, wvwFunctionAR -from rtk.gui.gtk.workviews import wvwRevisionGD, wvwRevisionAR +from rtk.gui.gtk.workviews import wvwFunctionGD +from rtk.gui.gtk.workviews import wvwRevisionGD from rtk.gui.gtk.workviews import wvwRequirementGD, wvwRequirementAnalysis from rtk.gui.gtk.workviews import wvwHardwareGD, wvwHardwareAI, wvwHardwareAR from rtk.gui.gtk.workviews import wvwValidationGD, wvwBurndownCurve @@ -44,12 +44,12 @@ def __init__(self, controller): # Initialize public dictionary attributes. self.dic_work_views = { - 'revision': [wvwRevisionGD(controller), - wvwRevisionAR(controller)], + 'revision': [ + wvwRevisionGD(controller), + ], 'function': [ wvwFunctionGD(controller), wvwFFMEA(controller), - wvwFunctionAR(controller) ], 'requirement': [wvwRequirementGD(controller), diff --git a/src/rtk/gui/gtk/workviews/Allocation.py b/src/rtk/gui/gtk/workviews/Allocation.py index d4fb18538..a76a9f32e 100644 --- a/src/rtk/gui/gtk/workviews/Allocation.py +++ b/src/rtk/gui/gtk/workviews/Allocation.py @@ -144,6 +144,29 @@ def __init__(self, controller, **kwargs): # pylint: disable=unused-argument self.show_all() pub.subscribe(self._on_select, 'selectedHardware') + pub.subscribe(self._do_clear_page, 'closedProgram') + + def _do_clear_page(self): + """ + Clear the contents of the page. + + :return: None + :rtype: None + """ + _model = self.treeview.get_model() + _columns = self.treeview.get_columns() + for _column in _columns: + self.treeview.remove_column(_column) + + _model.clear() + + self.cmbAllocationMethod.set_active(0) + self.cmbAllocationGoal.set_active(0) + self.txtHazardRateGoal.set_text('') + self.txtMTBFGoal.set_text('') + self.txtReliabilityGoal.set_text('') + + return None def _do_change_row(self, treeview): """ @@ -288,8 +311,7 @@ def _do_load_page(self, **kwargs): # pylint: disable=unused-argument "{0:s} for Hardware ID {1:s} is the " "wrong type for one or more " "columns.".format( - str(_node_id), - str(self._parent_id))) + str(_node_id), str(self._parent_id))) except ValueError: _error_code = 1 _user_msg = _(u"One or more Allocation line items was " @@ -298,8 +320,7 @@ def _do_load_page(self, **kwargs): # pylint: disable=unused-argument _debug_msg = ("RTK ERROR: Too few fields for " "Allocation ID {0:s} for Hardware ID " "{1:s}.".format( - str(_node_id), - str(self._parent_id))) + str(_node_id), str(self._parent_id))) except AttributeError: if _node_id != 0: _error_code = 1 @@ -309,8 +330,7 @@ def _do_load_page(self, **kwargs): # pylint: disable=unused-argument _debug_msg = ("RTK ERROR: There is no data package " "for Allocation ID {0:s} for Hardware " "ID {1:s}.".format( - str(_node_id), - str(self._parent_id))) + str(_node_id), str(self._parent_id))) return (_error_code, _user_msg, _debug_msg) diff --git a/src/rtk/gui/gtk/workviews/FMEA.py b/src/rtk/gui/gtk/workviews/FMEA.py index cc2e23cfc..453719638 100644 --- a/src/rtk/gui/gtk/workviews/FMEA.py +++ b/src/rtk/gui/gtk/workviews/FMEA.py @@ -522,6 +522,7 @@ def __init__(self, controller, **kwargs): # pylint: disable=unused-argument self.show_all() pub.subscribe(self._on_select, 'selectedFunction') + pub.subscribe(self._do_clear_page, 'closedProgram') def _do_change_row(self, treeview): """ @@ -603,6 +604,22 @@ def _do_change_row(self, treeview): return _return + def _do_clear_page(self): + """ + Clear the contents of the page. + + :return: None + :rtype: None + """ + _model = self.treeview.get_model() + _columns = self.treeview.get_columns() + for _column in _columns: + self.treeview.remove_column(_column) + + _model.clear() + + return None + def _do_edit_cell(self, __cell, path, new_text, position, model): """ Handle edits of the FMEA Work View RTKTreeview(). @@ -1002,6 +1019,7 @@ def __init__(self, controller, **kwargs): # pylint: disable=unused-argument pub.subscribe(self._do_load_missions, 'selectedRevision') pub.subscribe(self._on_select, 'selectedHardware') pub.subscribe(self._do_load_missions, 'editedUsage') + pub.subscribe(self._do_clear_page, 'closedProgram') def _do_change_row(self, treeview): """ @@ -1132,6 +1150,27 @@ def _do_change_row(self, treeview): return _return + def _do_clear_page(self): + """ + Clear the contents of the page. + + :return: None + :rtype: None + """ + _model = self.treeview.get_model() + _columns = self.treeview.get_columns() + for _column in _columns: + self.treeview.remove_column(_column) + + _model.clear() + + self.chkCriticality.set_active(False) + self.chkRPN.set_active(False) + _buffer = self.txtItemCriticality.do_get_buffer() + _buffer.set_text('') + + return None + def _do_edit_cell(self, __cell, path, new_text, position, model): """ Handle edits of the (D)FME(C)A RTKTreeview(). diff --git a/src/rtk/gui/gtk/workviews/Function.py b/src/rtk/gui/gtk/workviews/Function.py index 2727610ec..48abe5a73 100644 --- a/src/rtk/gui/gtk/workviews/Function.py +++ b/src/rtk/gui/gtk/workviews/Function.py @@ -107,6 +107,30 @@ def __init__(self, controller, **kwargs): # pylint: disable=unused-argument pub.subscribe(self._on_select, 'selectedFunction') pub.subscribe(self._on_edit, 'mvwEditedFunction') + pub.subscribe(self._do_clear_page, 'closedProgram') + + def _do_clear_page(self): + """ + Clear the contents of the page. + + :return: None + :rtype: None + """ + self.txtCode.handler_block(self._lst_handler_id[0]) + self.txtCode.set_text('') + self.txtCode.handler_unblock(self._lst_handler_id[0]) + self.txtName.handler_block(self._lst_handler_id[1]) + self.txtName.set_text('') + self.txtName.handler_unblock(self._lst_handler_id[1]) + _buffer = self.txtRemarks.do_get_buffer() + _buffer.handler_block(self._lst_handler_id[2]) + _buffer.set_text('') + _buffer.handler_block(self._lst_handler_id[2]) + self.chkSafetyCritical.handler_block(self._lst_handler_id[3]) + self.chkSafetyCritical.set_active(False) + self.chkSafetyCritical.handler_unblock(self._lst_handler_id[3]) + + return None def _do_load_page(self, **kwargs): # pylint: disable=unused-argument """ diff --git a/src/rtk/gui/gtk/workviews/Hardware.py b/src/rtk/gui/gtk/workviews/Hardware.py index d86060f9f..9d929f949 100644 --- a/src/rtk/gui/gtk/workviews/Hardware.py +++ b/src/rtk/gui/gtk/workviews/Hardware.py @@ -322,6 +322,108 @@ def __init__(self, controller, **kwargs): # pylint: disable=unused-argument pub.subscribe(self._do_load_subcategory, 'changedCategory') pub.subscribe(self._on_select, 'selectedHardware') pub.subscribe(self._on_edit, 'mvwEditedHardware') + pub.subscribe(self._do_clear_page, 'closedProgram') + + def _do_clear_page(self): + """ + Clear the contents of the page. + + :return: None + :rtype: None + """ + self.cmbCategory.set_active(0) + self.cmbSubcategory.handler_block(self._lst_handler_id[5]) + self.cmbSubcategory.set_active(0) + self.cmbSubcategory.handler_unblock(self._lst_handler_id[5]) + + self.chkRepairable.handler_block(self._lst_handler_id[0]) + self.chkRepairable.set_active(False) + self.chkRepairable.handler_unblock(self._lst_handler_id[0]) + + self.chkTagged.handler_block(self._lst_handler_id[1]) + self.chkTagged.set_active(False) + self.chkTagged.handler_unblock(self._lst_handler_id[1]) + + self.cmbCostType.handler_block(self._lst_handler_id[3]) + self.cmbCostType.set_active(0) + self.cmbCostType.handler_unblock(self._lst_handler_id[3]) + + self.cmbManufacturer.handler_block(self._lst_handler_id[4]) + self.cmbManufacturer.set_active(0) + self.cmbManufacturer.handler_unblock(self._lst_handler_id[4]) + + self.txtAltPartNum.handler_block(self._lst_handler_id[6]) + self.txtAltPartNum.set_text('') + self.txtAltPartNum.handler_unblock(self._lst_handler_id[6]) + + _textbuffer = self.txtAttachments.do_get_buffer() + _textbuffer.handler_block(self._lst_handler_id[7]) + _textbuffer.set_text('') + _textbuffer.handler_unblock(self._lst_handler_id[7]) + + self.txtCAGECode.handler_block(self._lst_handler_id[8]) + self.txtCAGECode.set_text('') + self.txtCAGECode.handler_unblock(self._lst_handler_id[8]) + + self.txtCompRefDes.handler_block(self._lst_handler_id[9]) + self.txtCompRefDes.set_text('') + self.txtCompRefDes.handler_unblock(self._lst_handler_id[9]) + + self.txtCost.handler_block(self._lst_handler_id[10]) + self.txtCost.set_text('') + self.txtCost.handler_unblock(self._lst_handler_id[10]) + + _textbuffer = self.txtDescription.do_get_buffer() + _textbuffer.handler_block(self._lst_handler_id[11]) + _textbuffer.set_text('') + _textbuffer.handler_unblock(self._lst_handler_id[11]) + + self.txtFigureNumber.handler_block(self._lst_handler_id[12]) + self.txtFigureNumber.set_text('') + self.txtFigureNumber.handler_unblock(self._lst_handler_id[12]) + + self.txtLCN.handler_block(self._lst_handler_id[13]) + self.txtLCN.set_text('') + self.txtLCN.handler_unblock(self._lst_handler_id[13]) + + self.txtName.handler_block(self._lst_handler_id[14]) + self.txtName.set_text('') + self.txtName.handler_unblock(self._lst_handler_id[14]) + + self.txtNSN.handler_block(self._lst_handler_id[15]) + self.txtNSN.set_text('') + self.txtNSN.handler_unblock(self._lst_handler_id[15]) + + self.txtPageNumber.handler_block(self._lst_handler_id[16]) + self.txtPageNumber.set_text('') + self.txtPageNumber.handler_unblock(self._lst_handler_id[16]) + + self.txtPartNumber.handler_block(self._lst_handler_id[17]) + self.txtPartNumber.set_text('') + self.txtPartNumber.handler_unblock(self._lst_handler_id[17]) + + self.txtQuantity.handler_block(self._lst_handler_id[18]) + self.txtQuantity.set_text('') + self.txtQuantity.handler_unblock(self._lst_handler_id[18]) + + self.txtRefDes.handler_block(self._lst_handler_id[19]) + self.txtRefDes.set_text('') + self.txtRefDes.handler_unblock(self._lst_handler_id[19]) + + _textbuffer = self.txtRemarks.do_get_buffer() + _textbuffer.handler_block(self._lst_handler_id[20]) + _textbuffer.set_text('') + _textbuffer.handler_unblock(self._lst_handler_id[20]) + + self.txtSpecification.handler_block(self._lst_handler_id[21]) + self.txtSpecification.set_text('') + self.txtSpecification.handler_unblock(self._lst_handler_id[21]) + + self.txtYearMade.handler_block(self._lst_handler_id[22]) + self.txtYearMade.set_text('') + self.txtYearMade.handler_unblock(self._lst_handler_id[22]) + + return None def _do_load_page(self, **kwargs): # pylint: disable=unused-argument """ @@ -1202,6 +1304,95 @@ def __init__(self, controller, **kwargs): # pylint: disable=unused-argument pub.subscribe(self._on_select, 'selectedHardware') pub.subscribe(self._on_edit, 'mvwEditedHardware') + pub.subscribe(self._do_clear_page, 'closedProgram') + + def _do_clear_page(self): + """ + Clear the contents of the page. + + :return: None + :rtype: None + """ + self.txtDutyCycle.handler_block(self._lst_handler_id[16]) + self.txtDutyCycle.set_text('') + self.txtDutyCycle.handler_unblock(self._lst_handler_id[16]) + + self.txtMissionTime.handler_block(self._lst_handler_id[17]) + self.txtMissionTime.set_text('') + self.txtMissionTime.handler_unblock(self._lst_handler_id[17]) + + # Clear the component-specific gtk.ScrolledWindow()s. + for _child in self.scwDesignRatings.get_children(): + self.scwDesignRatings.remove(_child) + + for _child in self.scwOperatingStress.get_children(): + self.scwOperatingStress.remove(_child) + + self.cmbActiveEnviron.handler_block(self._lst_handler_id[0]) + self.cmbActiveEnviron.set_active(0) + self.cmbActiveEnviron.handler_unblock(self._lst_handler_id[0]) + + self.cmbDormantEnviron.handler_block(self._lst_handler_id[1]) + self.cmbDormantEnviron.set_active(0) + self.cmbDormantEnviron.handler_unblock(self._lst_handler_id[1]) + + self.txtActiveTemp.handler_block(self._lst_handler_id[5]) + self.txtActiveTemp.set_text('') + self.txtActiveTemp.handler_unblock(self._lst_handler_id[5]) + + self.txtDormantTemp.handler_block(self._lst_handler_id[7]) + self.txtDormantTemp.set_text('') + self.txtDormantTemp.handler_unblock(self._lst_handler_id[7]) + + self.cmbFailureDist.handler_block(self._lst_handler_id[2]) + self.cmbFailureDist.set_active(0) + self.cmbFailureDist.handler_unblock(self._lst_handler_id[2]) + + self.cmbHRType.handler_block(self._lst_handler_id[3]) + self.cmbHRType.set_active(0) + self.cmbHRType.handler_unblock(self._lst_handler_id[3]) + + self.cmbHRMethod.handler_block(self._lst_handler_id[4]) + self.cmbHRMethod.set_active(0) + self.cmbHRMethod.handler_unblock(self._lst_handler_id[4]) + + self.txtAddAdjFactor.handler_block(self._lst_handler_id[6]) + self.txtAddAdjFactor.set_text('') + self.txtAddAdjFactor.handler_unblock(self._lst_handler_id[6]) + + self.txtFailScale.handler_block(self._lst_handler_id[8]) + self.txtFailScale.set_text('') + self.txtFailScale.handler_unblock(self._lst_handler_id[8]) + + self.txtFailShape.handler_block(self._lst_handler_id[9]) + self.txtFailShape.set_text('') + self.txtFailShape.handler_unblock(self._lst_handler_id[9]) + + self.txtFailLocation.handler_block(self._lst_handler_id[10]) + self.txtFailLocation.set_text('') + self.txtFailLocation.handler_unblock(self._lst_handler_id[10]) + + self.txtMultAdjFactor.handler_block(self._lst_handler_id[11]) + self.txtMultAdjFactor.set_text('') + self.txtMultAdjFactor.handler_unblock(self._lst_handler_id[11]) + + self.txtSpecifiedHt.handler_block(self._lst_handler_id[12]) + self.txtSpecifiedHt.set_text('') + self.txtSpecifiedHt.handler_unblock(self._lst_handler_id[12]) + + self.txtSpecifiedHtVar.handler_block(self._lst_handler_id[13]) + self.txtSpecifiedHtVar.set_text('') + self.txtSpecifiedHtVar.handler_unblock(self._lst_handler_id[13]) + + self.txtSpecifiedMTBF.handler_block(self._lst_handler_id[14]) + self.txtSpecifiedMTBF.set_text('') + self.txtSpecifiedMTBF.handler_unblock(self._lst_handler_id[14]) + + self.txtSpecifiedMTBFVar.handler_block(self._lst_handler_id[15]) + self.txtSpecifiedMTBFVar.set_text('') + self.txtSpecifiedMTBFVar.handler_unblock(self._lst_handler_id[15]) + + return None def _do_load_page(self, **kwargs): # pylint: disable=unused-argument """ @@ -2183,6 +2374,50 @@ def __init__(self, controller, **kwargs): # pylint: disable=unused-argument pub.subscribe(self._on_select, 'selectedHardware') pub.subscribe(self._do_load_page, 'calculatedHardware') + pub.subscribe(self._do_clear_page, 'closedProgram') + + def _do_clear_page(self): + """ + Clear the contents of the page. + + :return: None + :rtype: None + """ + self.txtTotalCost.set_text('') + self.txtCostFailure.set_text('') + self.txtCostHour.set_text('') + self.txtPartCount.set_text('') + self.txtActiveHt.set_text('') + self.txtActiveHtVar.set_text('') + self.txtDormantHt.set_text('') + self.txtDormantHtVar.set_text('') + self.txtSoftwareHt.set_text('') + self.txtPercentHt.set_text('') + self.txtLogisticsAt.set_text('') + self.txtLogisticsAtVar.set_text('') + self.txtLogisticsHt.set_text('') + self.txtLogisticsHtVar.set_text('') + self.txtLogisticsMTBF.set_text('') + self.txtLogisticsMTBFVar.set_text('') + self.txtLogisticsRt.set_text('') + self.txtLogisticsRtVar.set_text('') + self.txtMissionAt.set_text('') + self.txtMissionAtVar.set_text('') + self.txtMissionHt.set_text('') + self.txtMissionHtVar.set_text('') + self.txtMissionMTBF.set_text('') + self.txtMissionMTBFVar.set_text('') + self.txtMissionRt.set_text('') + self.txtMissionRtVar.set_text('') + + # Clear the component-specific gtk.ScrolledWindow()s. + for _child in self.scwReliability.get_children(): + self.scwReliability.remove(_child) + + for _child in self.scwStress.get_children(): + self.scwStress.remove(_child) + + return None def _do_load_page(self, **kwargs): # pylint: disable=unused-argument """ diff --git a/src/rtk/gui/gtk/workviews/HazOps.py b/src/rtk/gui/gtk/workviews/HazOps.py index 26e3b9a8e..a1084e72c 100644 --- a/src/rtk/gui/gtk/workviews/HazOps.py +++ b/src/rtk/gui/gtk/workviews/HazOps.py @@ -124,6 +124,23 @@ def __init__(self, controller, **kwargs): # pylint: disable=unused-argument #pub.subscribe(self._do_refresh_view, 'calculatedHazOps') pub.subscribe(self._on_select, 'selectedHardware') + pub.subscribe(self._do_clear_page, 'closedProgram') + + def _do_clear_page(self): + """ + Clear the contents of the page. + + :return: None + :rtype: None + """ + _model = self.treeview.get_model() + _columns = self.treeview.get_columns() + for _column in _columns: + self.treeview.remove_column(_column) + + _model.clear() + + return None def _do_change_row(self, treeview): """ diff --git a/src/rtk/gui/gtk/workviews/PoF.py b/src/rtk/gui/gtk/workviews/PoF.py index e08d52ed0..1579330e8 100644 --- a/src/rtk/gui/gtk/workviews/PoF.py +++ b/src/rtk/gui/gtk/workviews/PoF.py @@ -100,6 +100,23 @@ def __init__(self, controller, **kwargs): # pylint: disable=unused-argument self.show_all() pub.subscribe(self._on_select, 'selectedHardware') + pub.subscribe(self._do_clear_page, 'closedProgram') + + def _do_clear_page(self): + """ + Clear the contents of the page. + + :return: None + :rtype: None + """ + _model = self.treeview.get_model() + _columns = self.treeview.get_columns() + for _column in _columns: + self.treeview.remove_column(_column) + + _model.clear() + + return None def _do_load_page(self, **kwargs): """ diff --git a/src/rtk/gui/gtk/workviews/Requirement.py b/src/rtk/gui/gtk/workviews/Requirement.py index 814e88736..86cc004a9 100644 --- a/src/rtk/gui/gtk/workviews/Requirement.py +++ b/src/rtk/gui/gtk/workviews/Requirement.py @@ -168,6 +168,60 @@ def __init__(self, controller, **kwargs): # pylint: disable=unused-argument pub.subscribe(self._on_select, 'selectedRequirement') pub.subscribe(self._on_edit, 'mvwEditedRequirement') pub.subscribe(self._on_edit, 'calculatedRequirement') + pub.subscribe(self._do_clear_page, 'closedProgram') + + def _do_clear_page(self): + """ + Clear the contents of the page. + + :return: None + :rtype: None + """ + self.txtCode.handler_block(self._lst_handler_id[0]) + self.txtCode.set_text('') + self.txtCode.handler_unblock(self._lst_handler_id[0]) + + self.txtName.handler_block(self._lst_handler_id[1]) + self.txtName.set_text('') + self.txtName.handler_unblock(self._lst_handler_id[1]) + + self.chkDerived.handler_block(self._lst_handler_id[3]) + self.chkDerived.set_active(False) + self.chkDerived.handler_unblock(self._lst_handler_id[3]) + + self.cmbRequirementType.handler_block(self._lst_handler_id[2]) + self.cmbRequirementType.set_active(0) + self.cmbRequirementType.handler_unblock(self._lst_handler_id[2]) + + self.txtSpecification.handler_block(self._lst_handler_id[4]) + self.txtSpecification.set_text('') + self.txtSpecification.handler_unblock(self._lst_handler_id[4]) + + self.txtPageNum.handler_block(self._lst_handler_id[5]) + self.txtPageNum.set_text('') + self.txtPageNum.handler_unblock(self._lst_handler_id[5]) + + self.txtFigNum.handler_block(self._lst_handler_id[6]) + self.txtFigNum.set_text('') + self.txtFigNum.handler_unblock(self._lst_handler_id[6]) + + self.cmbPriority.handler_block(self._lst_handler_id[7]) + self.cmbPriority.set_active(0) + self.cmbPriority.handler_unblock(self._lst_handler_id[7]) + + self.cmbOwner.handler_block(self._lst_handler_id[8]) + self.cmbOwner.set_active(0) + self.cmbOwner.handler_unblock(self._lst_handler_id[8]) + + self.chkValidated.handler_block(self._lst_handler_id[9]) + self.chkValidated.set_active(False) + self.chkValidated.handler_unblock(self._lst_handler_id[9]) + + self.txtValidatedDate.handler_block(self._lst_handler_id[10]) + self.txtValidatedDate.set_text('') + self.txtValidatedDate.handler_unblock(self._lst_handler_id[10]) + + return None def _do_load_page(self, **kwargs): # pylint: disable=unused-argument """ @@ -680,6 +734,27 @@ def __init__(self, controller, **kwargs): #pylint: disable=unused-argument self.show_all() pub.subscribe(self._on_select, 'selectedRequirement') + pub.subscribe(self._do_clear_page, 'closedProgram') + + def _do_clear_page(self): + """ + Clear the contents of the page. + + :return: None + :rtype: None + """ + for _treeview in [ + self.tvwClear, self.tvwComplete, self.tvwConsistent, + self.tvwVerifiable + ]: + _model = _treeview.get_model() + _columns = _treeview.get_columns() + for _column in _columns: + _treeview.remove_column(_column) + + _model.clear() + + return None def _do_request_update(self, __button): """ diff --git a/src/rtk/gui/gtk/workviews/Revision.py b/src/rtk/gui/gtk/workviews/Revision.py index a201f2c5e..eb5d91a20 100644 --- a/src/rtk/gui/gtk/workviews/Revision.py +++ b/src/rtk/gui/gtk/workviews/Revision.py @@ -6,8 +6,6 @@ # Copyright 2007 - 2017 Andrew Rowland andrew.rowland reliaqual com """Revision Work View.""" -import locale - from pubsub import pub # Import other RTK modules. @@ -69,10 +67,10 @@ def __init__(self, controller, **kwargs): # pylint: disable=unused-argument self.txtCode = rtk.RTKEntry( width=125, tooltip=_(u"A unique code for the selected revision.")) self.txtName = rtk.RTKEntry( - width=800, tooltip=_(u"The name of the selected revision.")) + width=600, tooltip=_(u"The name of the selected revision.")) self.txtRemarks = rtk.RTKTextView( gtk.TextBuffer(), - width=400, + width=600, tooltip=_(u"Enter any remarks associated with the " u"selected revision.")) @@ -89,6 +87,27 @@ def __init__(self, controller, **kwargs): # pylint: disable=unused-argument pub.subscribe(self._on_select, 'selectedRevision') pub.subscribe(self._on_edit, 'mvwEditedRevision') + pub.subscribe(self._do_clear_page, 'closedProgram') + + def _do_clear_page(self): + """ + Clear the contents of the page. + + :return: None + :rtype: None + """ + self.txtName.handler_block(self._lst_handler_id[0]) + self.txtName.set_text('') + self.txtName.handler_unblock(self._lst_handler_id[0]) + _buffer = self.txtRemarks.do_get_buffer() + _buffer.handler_block(self._lst_handler_id[1]) + _buffer.set_text('') + _buffer.handler_block(self._lst_handler_id[1]) + self.txtCode.handler_block(self._lst_handler_id[2]) + self.txtCode.set_text('') + self.txtCode.handler_unblock(self._lst_handler_id[2]) + + return None def _do_load_page(self, **kwargs): # pylint: disable=unused-argument """ @@ -102,16 +121,16 @@ def _do_load_page(self, **kwargs): # pylint: disable=unused-argument _revision = self._dtc_data_controller.request_do_select( self._revision_id) - self.txtTotalCost.set_text(str(locale.currency(_revision.cost))) - self.txtCostFailure.set_text( - str(locale.currency(_revision.cost_failure))) - self.txtCostHour.set_text(str(locale.currency(_revision.cost_hour))) + self.txtCode.handler_block(self._lst_handler_id[2]) + self.txtCode.set_text(str(_revision.revision_code)) + self.txtCode.handler_unblock(self._lst_handler_id[2]) + self.txtName.handler_block(self._lst_handler_id[0]) self.txtName.set_text(_revision.name) + self.txtName.handler_unblock(self._lst_handler_id[0]) _buffer = self.txtRemarks.do_get_buffer() + _buffer.handler_block(self._lst_handler_id[1]) _buffer.set_text(_revision.remarks) - self.txtPartCount.set_text( - str('{0:0.0f}'.format(_revision.total_part_count))) - self.txtCode.set_text(str(_revision.revision_code)) + _buffer.handler_unblock(self._lst_handler_id[1]) return _return diff --git a/src/rtk/gui/gtk/workviews/SimilarItem.py b/src/rtk/gui/gtk/workviews/SimilarItem.py index fc53582b5..3b8e8d020 100644 --- a/src/rtk/gui/gtk/workviews/SimilarItem.py +++ b/src/rtk/gui/gtk/workviews/SimilarItem.py @@ -131,6 +131,27 @@ def __init__(self, controller, **kwargs): # pylint: disable=unused-argument #pub.subscribe(self._do_refresh_view, 'calculatedSimilarItem') #pub.subscribe(self._on_select_revision, 'selectedRevision') pub.subscribe(self._on_select, 'selectedHardware') + pub.subscribe(self._do_clear_page, 'closedProgram') + + def _do_clear_page(self): + """ + Clear the contents of the page. + + :return: None + :rtype: None + """ + _model = self.treeview.get_model() + _columns = self.treeview.get_columns() + for _column in _columns: + self.treeview.remove_column(_column) + + _model.clear() + + self.cmbSimilarItemMethod.handler_block(self._lst_handler_id[2]) + self.cmbSimilarItemMethod.set_active(0) + self.cmbSimilarItemMethod.handler_unblock(self._lst_handler_id[2]) + + return None def _do_change_row(self, treeview): """ diff --git a/src/rtk/gui/gtk/workviews/Validation.py b/src/rtk/gui/gtk/workviews/Validation.py index ad7a6fd30..1830b7a6d 100644 --- a/src/rtk/gui/gtk/workviews/Validation.py +++ b/src/rtk/gui/gtk/workviews/Validation.py @@ -281,6 +281,94 @@ def __init__(self, controller, **kwargs): # pylint: disable=unused-argument pub.subscribe(self._on_select, 'selectedValidation') pub.subscribe(self._on_select, 'calculatedValidation') pub.subscribe(self._on_edit, 'mvwEditedValidation') + pub.subscribe(self._do_clear_page, 'closedProgram') + + def _do_clear_page(self): + """ + Clear the contents of the page. + + :return: None + :rtype: None + """ + self.txtID.set_text('') + + _buffer = self.txtTask.do_get_buffer() + _buffer.handler_block(self._lst_handler_id[0]) + _buffer.set_text('') + _buffer.handler_unblock(self._lst_handler_id[0]) + + self.cmbTaskType.handler_block(self._lst_handler_id[1]) + self.cmbTaskType.set_active(0) + self.cmbTaskType.handler_unblock(self._lst_handler_id[1]) + + self.txtSpecification.handler_block(self._lst_handler_id[2]) + self.txtSpecification.set_text('') + self.txtSpecification.handler_unblock(self._lst_handler_id[2]) + + self.cmbMeasurementUnit.handler_block(self._lst_handler_id[3]) + self.cmbMeasurementUnit.set_active(0) + self.cmbMeasurementUnit.handler_unblock(self._lst_handler_id[3]) + + self.txtMinAcceptable.handler_block(self._lst_handler_id[4]) + self.txtMinAcceptable.set_text('') + self.txtMinAcceptable.handler_unblock(self._lst_handler_id[4]) + + self.txtMeanAcceptable.handler_block(self._lst_handler_id[5]) + self.txtMeanAcceptable.set_text('') + self.txtMeanAcceptable.handler_unblock(self._lst_handler_id[5]) + + self.txtMaxAcceptable.handler_block(self._lst_handler_id[6]) + self.txtMaxAcceptable.set_text('') + self.txtMaxAcceptable.handler_unblock(self._lst_handler_id[6]) + + self.txtVarAcceptable.handler_block(self._lst_handler_id[7]) + self.txtVarAcceptable.set_text('') + self.txtVarAcceptable.handler_unblock(self._lst_handler_id[7]) + + self.txtStartDate.handler_block(self._lst_handler_id[8]) + self.txtStartDate.set_text('') + self.txtStartDate.handler_unblock(self._lst_handler_id[8]) + + self.txtEndDate.handler_block(self._lst_handler_id[9]) + self.txtEndDate.set_text('') + self.txtEndDate.handler_unblock(self._lst_handler_id[9]) + + self.spnStatus.handler_block(self._lst_handler_id[10]) + self.spnStatus.set_value(0.0) + self.spnStatus.handler_unblock(self._lst_handler_id[10]) + + self.txtMinTime.handler_block(self._lst_handler_id[11]) + self.txtMinTime.set_text('') + self.txtMinTime.handler_unblock(self._lst_handler_id[11]) + + self.txtExpTime.handler_block(self._lst_handler_id[12]) + self.txtExpTime.set_text('') + self.txtExpTime.handler_unblock(self._lst_handler_id[12]) + + self.txtMaxTime.handler_block(self._lst_handler_id[13]) + self.txtMaxTime.set_text('') + self.txtMaxTime.handler_unblock(self._lst_handler_id[13]) + + self.txtMinCost.handler_block(self._lst_handler_id[14]) + self.txtMinCost.set_text('') + self.txtMinCost.handler_unblock(self._lst_handler_id[14]) + + self.txtExpCost.handler_block(self._lst_handler_id[15]) + self.txtExpCost.set_text('') + self.txtExpCost.handler_unblock(self._lst_handler_id[15]) + + self.txtMaxCost.handler_block(self._lst_handler_id[16]) + self.txtMaxCost.set_text('') + self.txtMaxCost.handler_unblock(self._lst_handler_id[16]) + + self.txtMeanTimeLL.set_text('') + self.txtMeanTime.set_text('') + self.txtMeanTimeUL.set_text('') + self.txtMeanCostLL.set_text('') + self.txtMeanCost.set_text('') + self.txtMeanCostUL.set_text('') + + return None def _do_load_page(self, **kwargs): # pylint: disable=unused-argument """ @@ -1044,6 +1132,20 @@ def __init__(self, controller, **kwargs): # pylint: disable=unused-argument pub.subscribe(self._on_select, 'selectedValidation') pub.subscribe(self._do_request_plot, 'calculatedProgram') + pub.subscribe(self._do_clear_page, 'closedProgram') + + def _do_clear_page(self): + """ + Clear the contents of the page. + + :return: None + :rtype: None + """ + self.burndown.axis.cla() + self.burndown.figure.clf() + self.burndown.plot.draw() + + return None def _do_load_page(self, **kwargs): # pylint: disable=unused-argument """