diff --git a/setoolsgui/apol/boolquery.py b/setoolsgui/apol/boolquery.py index 2fd295b..34b7cc4 100644 --- a/setoolsgui/apol/boolquery.py +++ b/setoolsgui/apol/boolquery.py @@ -65,6 +65,7 @@ class BoolQueryTab(AnalysisTab): self.table_results.sortByColumn(0, Qt.AscendingOrder) # setup indications of errors on level/range + self.errors = set() self.orig_palette = self.name.palette() self.error_palette = self.name.palette() self.error_palette.setColor(QPalette.Base, Qt.red) @@ -118,16 +119,14 @@ class BoolQueryTab(AnalysisTab): # Name criteria # def clear_name_error(self): - self.name.setToolTip("Match the Boolean name.") - self.name.setPalette(self.orig_palette) + self.clear_criteria_error(self.name, "Match the Boolean name.") def set_name(self): try: self.query.name = self.name.text() except Exception as ex: self.log.error("Boolean name error: {0}".format(ex)) - self.name.setToolTip("Error: " + str(ex)) - self.name.setPalette(self.error_palette) + self.set_criteria_error(self.name, ex) def set_name_regex(self, state): self.log.debug("Setting name_regex {0}".format(state)) diff --git a/setoolsgui/apol/boundsquery.py b/setoolsgui/apol/boundsquery.py index adfa54f..395ddfc 100644 --- a/setoolsgui/apol/boundsquery.py +++ b/setoolsgui/apol/boundsquery.py @@ -60,6 +60,7 @@ class BoundsQueryTab(AnalysisTab): self.table_results.sortByColumn(1, Qt.AscendingOrder) # setup indications of errors on level/range + self.errors = set() self.orig_palette = self.parent.palette() self.error_palette = self.parent.palette() self.error_palette.setColor(QPalette.Base, Qt.red) @@ -104,16 +105,14 @@ class BoundsQueryTab(AnalysisTab): # Parent criteria # def clear_parent_error(self): - self.parent.setToolTip("Match the parent type.") - self.parent.setPalette(self.orig_palette) + self.clear_criteria_error(self.parent, "Match the parent type.") def set_parent(self): try: self.query.parent = self.parent.text() except Exception as ex: self.log.error("Type parent error: {0}".format(ex)) - self.parent.setToolTip("Error: " + str(ex)) - self.parent.setPalette(self.error_palette) + self.set_criteria_error(self.parent, ex) def set_parent_regex(self, state): self.log.debug("Setting parent_regex {0}".format(state)) @@ -125,16 +124,14 @@ class BoundsQueryTab(AnalysisTab): # Child criteria # def clear_child_error(self): - self.child.setToolTip("Match the child type.") - self.child.setPalette(self.orig_palette) + self.clear_criteria_error(self.child, "Match the child type.") def set_child(self): try: self.query.child = self.child.text() except Exception as ex: self.log.error("Type child error: {0}".format(ex)) - self.child.setToolTip("Error: " + str(ex)) - self.child.setPalette(self.error_palette) + self.set_criteria_error(self.child, ex) def set_child_regex(self, state): self.log.debug("Setting child_regex {0}".format(state)) diff --git a/setoolsgui/apol/categoryquery.py b/setoolsgui/apol/categoryquery.py index 8689cc4..fcf47b0 100644 --- a/setoolsgui/apol/categoryquery.py +++ b/setoolsgui/apol/categoryquery.py @@ -65,6 +65,7 @@ class CategoryQueryTab(AnalysisTab): self.table_results.sortByColumn(0, Qt.AscendingOrder) # setup indications of errors on level/range + self.errors = set() self.orig_palette = self.name.palette() self.error_palette = self.name.palette() self.error_palette.setColor(QPalette.Base, Qt.red) @@ -118,16 +119,14 @@ class CategoryQueryTab(AnalysisTab): # Name criteria # def clear_name_error(self): - self.name.setToolTip("Match the category name.") - self.name.setPalette(self.orig_palette) + self.clear_criteria_error(self.name, "Match the category name.") def set_name(self): try: self.query.name = self.name.text() except Exception as ex: self.log.error("Category name error: {0}".format(ex)) - self.name.setToolTip("Error: " + str(ex)) - self.name.setPalette(self.error_palette) + self.set_criteria_error(self.name, ex) def set_name_regex(self, state): self.log.debug("Setting name_regex {0}".format(state)) diff --git a/setoolsgui/apol/commonquery.py b/setoolsgui/apol/commonquery.py index 160501a..3c989da 100644 --- a/setoolsgui/apol/commonquery.py +++ b/setoolsgui/apol/commonquery.py @@ -73,6 +73,7 @@ class CommonQueryTab(AnalysisTab): self.table_results.sortByColumn(0, Qt.AscendingOrder) # setup indications of errors + self.errors = set() self.orig_palette = self.name.palette() self.error_palette = self.name.palette() self.error_palette.setColor(QPalette.Base, Qt.red) @@ -129,16 +130,14 @@ class CommonQueryTab(AnalysisTab): # Name criteria # def clear_name_error(self): - self.name.setToolTip("Match the common name.") - self.name.setPalette(self.orig_palette) + self.clear_criteria_error(self.name, "Match the common name.") def set_name(self): try: self.query.name = self.name.text() except Exception as ex: self.log.error("Common name error: {0}".format(ex)) - self.name.setToolTip("Error: " + str(ex)) - self.name.setPalette(self.error_palette) + self.set_criteria_error(self.name, ex) def set_name_regex(self, state): self.log.debug("Setting name_regex {0}".format(state)) diff --git a/setoolsgui/apol/constraintquery.py b/setoolsgui/apol/constraintquery.py index a5fb083..2d4a68b 100644 --- a/setoolsgui/apol/constraintquery.py +++ b/setoolsgui/apol/constraintquery.py @@ -86,6 +86,7 @@ class ConstraintQueryTab(AnalysisTab): self.perms.setModel(self.perms_model) # setup indications of errors + self.errors = set() self.orig_palette = self.type_.palette() self.error_palette = self.type_.palette() self.error_palette.setColor(QPalette.Base, Qt.red) @@ -202,16 +203,15 @@ class ConstraintQueryTab(AnalysisTab): # User criteria # def clear_user_error(self): - self.user.setToolTip("Match constraints that have a user in the expression.") - self.user.setPalette(self.orig_palette) + self.clear_criteria_error(self.user, + "Match constraints that have a user in the expression.") def set_user(self): try: self.query.user = self.user.text() except Exception as ex: self.log.error("User error: {0}".format(ex)) - self.user.setToolTip("Error: " + str(ex)) - self.user.setPalette(self.error_palette) + self.set_criteria_error(self.user, ex) def set_user_regex(self, state): self.log.debug("Setting user_regex {0}".format(state)) @@ -223,16 +223,15 @@ class ConstraintQueryTab(AnalysisTab): # Role criteria # def clear_role_error(self): - self.role.setToolTip("Match constraints that have a role in the expression.") - self.role.setPalette(self.orig_palette) + self.clear_criteria_error(self.role, + "Match constraints that have a role in the expression.") def set_role(self): try: self.query.role = self.role.text() except Exception as ex: self.log.error("Role error: {0}".format(ex)) - self.role.setToolTip("Error: " + str(ex)) - self.role.setPalette(self.error_palette) + self.set_criteria_error(self.role, ex) def set_role_regex(self, state): self.log.debug("Setting role_regex {0}".format(state)) @@ -244,16 +243,15 @@ class ConstraintQueryTab(AnalysisTab): # Type criteria # def clear_type_error(self): - self.type_.setToolTip("Match constraints that have a type in the expression.") - self.type_.setPalette(self.orig_palette) + self.clear_criteria_error(self.type_, + "Match constraints that have a type in the expression.") def set_type(self): try: self.query.type_ = self.type_.text() except Exception as ex: self.log.error("Type error: {0}".format(ex)) - self.type_.setToolTip("Error: " + str(ex)) - self.type_.setPalette(self.error_palette) + self.set_criteria_error(self.type_, ex) def set_type_regex(self, state): self.log.debug("Setting type_regex {0}".format(state)) diff --git a/setoolsgui/apol/dta.py b/setoolsgui/apol/dta.py index 533a28f..d77b38f 100644 --- a/setoolsgui/apol/dta.py +++ b/setoolsgui/apol/dta.py @@ -64,6 +64,7 @@ class DomainTransitionAnalysisTab(AnalysisTab): self.target.setCompleter(self.type_completion) # setup indications of errors on source/target/default + self.errors = set() self.orig_palette = self.source.palette() self.error_palette = self.source.palette() self.error_palette.setColor(QPalette.Base, Qt.red) @@ -153,14 +154,8 @@ class DomainTransitionAnalysisTab(AnalysisTab): # # Source criteria # - def set_source_error(self, error_text): - self.log.error("Source domain error: {0}".format(error_text)) - self.source.setToolTip("Error: {0}".format(error_text)) - self.source.setPalette(self.error_palette) - def clear_source_error(self): - self.source.setToolTip("The source domain of the analysis.") - self.source.setPalette(self.orig_palette) + self.clear_criteria_error(self.source, "The source domain of the analysis.") def set_source(self): try: @@ -171,19 +166,14 @@ class DomainTransitionAnalysisTab(AnalysisTab): else: self.query.source = None except Exception as ex: - self.set_source_error(ex) + self.log.error("Source domain error: {0}".format(str(ex))) + self.set_criteria_error(self.source, ex) # # Target criteria # - def set_target_error(self, error_text): - self.log.error("Target domain error: {0}".format(error_text)) - self.target.setToolTip("Error: {0}".format(error_text)) - self.target.setPalette(self.error_palette) - def clear_target_error(self): - self.target.setToolTip("The target domain of the analysis.") - self.target.setPalette(self.orig_palette) + self.clear_criteria_error(self.target, "The target domain of the analysis.") def set_target(self): try: @@ -194,7 +184,8 @@ class DomainTransitionAnalysisTab(AnalysisTab): else: self.query.target = None except Exception as ex: - self.set_target_error(ex) + self.log.error("Target domain error: {0}".format(str(ex))) + self.set_criteria_error(self.target, ex) # # Options @@ -321,14 +312,12 @@ class DomainTransitionAnalysisTab(AnalysisTab): # right now there is only one button. fail = False if self.source.isEnabled() and not self.query.source: - self.set_source_error("A source domain is required") - fail = True + self.set_criteria_error(self.source, "A source domain is required") if self.target.isEnabled() and not self.query.target: - self.set_target_error("A target domain is required.") - fail = True + self.set_criteria_error(self.target, "A target domain is required.") - if fail: + if self.errors: return for mode in [self.all_paths, self.all_shortest_paths, self.flows_in, self.flows_out]: diff --git a/setoolsgui/apol/fsusequery.py b/setoolsgui/apol/fsusequery.py index b2ca92e..c30fe76 100644 --- a/setoolsgui/apol/fsusequery.py +++ b/setoolsgui/apol/fsusequery.py @@ -76,6 +76,7 @@ class FSUseQueryTab(AnalysisTab): self.type_.setCompleter(self.type_completion) # setup indications of errors on source/target/default + self.errors = set() self.orig_palette = self.type_.palette() self.error_palette = self.type_.palette() self.error_palette.setColor(QPalette.Base, Qt.red) @@ -166,16 +167,14 @@ class FSUseQueryTab(AnalysisTab): # FS criteria # def clear_fs_error(self): - self.fs.setToolTip("Match the filesystem type.") - self.fs.setPalette(self.orig_palette) + self.clear_criteria_error(self.fs, "Match the filesystem type.") def set_fs(self): try: self.query.fs = self.fs.text() except Exception as ex: self.log.error("Filesystem type error: {0}".format(ex)) - self.fs.setToolTip("Error: " + str(ex)) - self.fs.setPalette(self.error_palette) + self.set_criteria_error(self.fs, ex) def set_fs_regex(self, state): self.log.debug("Setting fs_regex {0}".format(state)) @@ -187,16 +186,14 @@ class FSUseQueryTab(AnalysisTab): # User criteria # def clear_user_error(self): - self.user.setToolTip("Match the user of the context.") - self.user.setPalette(self.orig_palette) + self.clear_criteria_error(self.user, "Match the user of the context.") def set_user(self): try: self.query.user = self.user.text() except Exception as ex: self.log.error("Context user error: {0}".format(ex)) - self.user.setToolTip("Error: " + str(ex)) - self.user.setPalette(self.error_palette) + self.set_criteria_error(self.user, ex) def set_user_regex(self, state): self.log.debug("Setting user_regex {0}".format(state)) @@ -208,16 +205,14 @@ class FSUseQueryTab(AnalysisTab): # Role criteria # def clear_role_error(self): - self.role.setToolTip("Match the role of the context.") - self.role.setPalette(self.orig_palette) + self.clear_criteria_error(self.role, "Match the role of the context.") def set_role(self): try: self.query.role = self.role.text() except Exception as ex: self.log.error("Context role error: {0}".format(ex)) - self.role.setToolTip("Error: " + str(ex)) - self.role.setPalette(self.error_palette) + self.set_criteria_error(self.role, ex) def set_role_regex(self, state): self.log.debug("Setting role_regex {0}".format(state)) @@ -229,16 +224,14 @@ class FSUseQueryTab(AnalysisTab): # Type criteria # def clear_type_error(self): - self.type_.setToolTip("Match the type of the context.") - self.type_.setPalette(self.orig_palette) + self.clear_criteria_error(self.type_, "Match the type of the context.") def set_type(self): try: self.query.type_ = self.type_.text() except Exception as ex: self.log.error("Context type error: {0}".format(ex)) - self.type_.setToolTip("Error: " + str(ex)) - self.type_.setPalette(self.error_palette) + self.set_criteria_error(self.type_, ex) def set_type_regex(self, state): self.log.debug("Setting type_regex {0}".format(state)) @@ -250,16 +243,14 @@ class FSUseQueryTab(AnalysisTab): # Range criteria # def clear_range_error(self): - self.range_.setToolTip("Match the range of the context.") - self.range_.setPalette(self.orig_palette) + self.clear_criteria_error(self.range_, "Match the range of the context.") def set_range(self): try: self.query.range_ = self.range_.text() except Exception as ex: self.log.info("Context range error: " + str(ex)) - self.range_.setToolTip("Error: " + str(ex)) - self.range_.setPalette(self.error_palette) + self.set_criteria_error(self.range_, ex) # # Save/Load tab diff --git a/setoolsgui/apol/genfsconquery.py b/setoolsgui/apol/genfsconquery.py index e588670..c9dfbe5 100644 --- a/setoolsgui/apol/genfsconquery.py +++ b/setoolsgui/apol/genfsconquery.py @@ -76,6 +76,7 @@ class GenfsconQueryTab(AnalysisTab): self.type_.setCompleter(self.type_completion) # setup indications of errors on source/target/default + self.errors = set() self.orig_palette = self.type_.palette() self.error_palette = self.type_.palette() self.error_palette.setColor(QPalette.Base, Qt.red) @@ -154,16 +155,14 @@ class GenfsconQueryTab(AnalysisTab): # FS criteria # def clear_fs_error(self): - self.fs.setToolTip("Match the filesystem type.") - self.fs.setPalette(self.orig_palette) + self.clear_criteria_error(self.fs, "Match the filesystem type.") def set_fs(self): try: self.query.fs = self.fs.text() except Exception as ex: self.log.error("Filesystem type error: {0}".format(ex)) - self.fs.setToolTip("Error: " + str(ex)) - self.fs.setPalette(self.error_palette) + self.set_criteria_error(self.fs, ex) def set_fs_regex(self, state): self.log.debug("Setting fs_regex {0}".format(state)) @@ -175,16 +174,14 @@ class GenfsconQueryTab(AnalysisTab): # Path criteria # def clear_path_error(self): - self.path.setToolTip("Match the path.") - self.path.setPalette(self.orig_palette) + self.clear_criteria_error(self.path, "Match the path.") def set_path(self): try: self.query.path = self.path.text() except Exception as ex: self.log.error("Path error: {0}".format(ex)) - self.path.setToolTip("Error: " + str(ex)) - self.path.setPalette(self.error_palette) + self.set_criteria_error(self.path, ex) def set_path_regex(self, state): self.log.debug("Setting path_regex {0}".format(state)) @@ -196,16 +193,14 @@ class GenfsconQueryTab(AnalysisTab): # User criteria # def clear_user_error(self): - self.user.setToolTip("Match the user of the context.") - self.user.setPalette(self.orig_palette) + self.clear_criteria_error(self.user, "Match the user of the context.") def set_user(self): try: self.query.user = self.user.text() except Exception as ex: self.log.error("Context user error: {0}".format(ex)) - self.user.setToolTip("Error: " + str(ex)) - self.user.setPalette(self.error_palette) + self.set_criteria_error(self.user, ex) def set_user_regex(self, state): self.log.debug("Setting user_regex {0}".format(state)) @@ -217,16 +212,14 @@ class GenfsconQueryTab(AnalysisTab): # Role criteria # def clear_role_error(self): - self.role.setToolTip("Match the role of the context.") - self.role.setPalette(self.orig_palette) + self.clear_criteria_error(self.role, "Match the role of the context.") def set_role(self): try: self.query.role = self.role.text() except Exception as ex: self.log.error("Context role error: {0}".format(ex)) - self.role.setToolTip("Error: " + str(ex)) - self.role.setPalette(self.error_palette) + self.set_criteria_error(self.role, ex) def set_role_regex(self, state): self.log.debug("Setting role_regex {0}".format(state)) @@ -238,16 +231,14 @@ class GenfsconQueryTab(AnalysisTab): # Type criteria # def clear_type_error(self): - self.type_.setToolTip("Match the type of the context.") - self.type_.setPalette(self.orig_palette) + self.clear_criteria_error(self.type_, "Match the type of the context.") def set_type(self): try: self.query.type_ = self.type_.text() except Exception as ex: self.log.error("Context type error: {0}".format(ex)) - self.type_.setToolTip("Error: " + str(ex)) - self.type_.setPalette(self.error_palette) + self.set_criteria_error(self.type_, ex) def set_type_regex(self, state): self.log.debug("Setting type_regex {0}".format(state)) @@ -259,16 +250,14 @@ class GenfsconQueryTab(AnalysisTab): # Range criteria # def clear_range_error(self): - self.range_.setToolTip("Match the range of the context.") - self.range_.setPalette(self.orig_palette) + self.clear_criteria_error(self.range_, "Match the range of the context.") def set_range(self): try: self.query.range_ = self.range_.text() except Exception as ex: self.log.info("Context range error: " + str(ex)) - self.range_.setToolTip("Error: " + str(ex)) - self.range_.setPalette(self.error_palette) + self.set_criteria_error(self.range_, ex) # # Save/Load tab diff --git a/setoolsgui/apol/infoflow.py b/setoolsgui/apol/infoflow.py index e48c6d1..dde49b4 100644 --- a/setoolsgui/apol/infoflow.py +++ b/setoolsgui/apol/infoflow.py @@ -97,6 +97,7 @@ class InfoFlowAnalysisTab(AnalysisTab): self.target.setCompleter(self.type_completion) # setup indications of errors on source/target/default + self.errors = set() self.orig_palette = self.source.palette() self.error_palette = self.source.palette() self.error_palette.setColor(QPalette.Base, Qt.red) @@ -173,14 +174,8 @@ class InfoFlowAnalysisTab(AnalysisTab): # # Source criteria # - def set_source_error(self, error_text): - self.log.error("Source type error: {0}".format(error_text)) - self.source.setToolTip("Error: {0}".format(error_text)) - self.source.setPalette(self.error_palette) - def clear_source_error(self): - self.source.setToolTip("The source type of the analysis.") - self.source.setPalette(self.orig_palette) + self.clear_criteria_error(self.source, "The source type of the analysis.") def set_source(self): try: @@ -191,19 +186,14 @@ class InfoFlowAnalysisTab(AnalysisTab): else: self.query.source = None except Exception as ex: - self.set_source_error(ex) + self.log.error("Source type error: {0}".format(str(ex))) + self.set_criteria_error(self.source, ex) # # Target criteria # - def set_target_error(self, error_text): - self.log.error("Target type error: {0}".format(error_text)) - self.target.setToolTip("Error: {0}".format(error_text)) - self.target.setPalette(self.error_palette) - def clear_target_error(self): - self.target.setToolTip("The target type of the analysis.") - self.target.setPalette(self.orig_palette) + self.clear_criteria_error(self.target, "The target type of the analysis.") def set_target(self): try: @@ -214,7 +204,8 @@ class InfoFlowAnalysisTab(AnalysisTab): else: self.query.target = None except Exception as ex: - self.set_target_error(ex) + self.log.error("Target type error: {0}".format(str(ex))) + self.set_criteria_error(self.target, ex) # # Options @@ -367,11 +358,11 @@ class InfoFlowAnalysisTab(AnalysisTab): # right now there is only one button. fail = False if self.source.isEnabled() and not self.query.source: - self.set_source_error("A source type is required") + self.set_criteria_error(self.source, "A source type is required") fail = True if self.target.isEnabled() and not self.query.target: - self.set_target_error("A target type is required.") + self.set_criteria_error(self.target, "A target type is required.") fail = True if not self.perm_map: diff --git a/setoolsgui/apol/initsidquery.py b/setoolsgui/apol/initsidquery.py index ab57032..ed19eb8 100644 --- a/setoolsgui/apol/initsidquery.py +++ b/setoolsgui/apol/initsidquery.py @@ -76,6 +76,7 @@ class InitialSIDQueryTab(AnalysisTab): self.type_.setCompleter(self.type_completion) # setup indications of errors on source/target/default + self.errors = set() self.orig_palette = self.type_.palette() self.error_palette = self.type_.palette() self.error_palette.setColor(QPalette.Base, Qt.red) @@ -150,16 +151,14 @@ class InitialSIDQueryTab(AnalysisTab): # Name criteria # def clear_name_error(self): - self.name.setToolTip("Match the name.") - self.name.setPalette(self.orig_palette) + self.clear_criteria_error(self.name, "Match the name.") def set_name(self): try: self.query.name = self.name.text() except Exception as ex: self.log.error("Name error: {0}".format(ex)) - self.name.setToolTip("Error: " + str(ex)) - self.name.setPalette(self.error_palette) + self.set_criteria_error(self.name, ex) def set_name_regex(self, state): self.log.debug("Setting name_regex {0}".format(state)) @@ -171,16 +170,14 @@ class InitialSIDQueryTab(AnalysisTab): # User criteria # def clear_user_error(self): - self.user.setToolTip("Match the user of the context.") - self.user.setPalette(self.orig_palette) + self.clear_criteria_error(self.user, "Match the user of the context.") def set_user(self): try: self.query.user = self.user.text() except Exception as ex: self.log.error("Context user error: {0}".format(ex)) - self.user.setToolTip("Error: " + str(ex)) - self.user.setPalette(self.error_palette) + self.set_criteria_error(self.user, ex) def set_user_regex(self, state): self.log.debug("Setting user_regex {0}".format(state)) @@ -192,16 +189,14 @@ class InitialSIDQueryTab(AnalysisTab): # Role criteria # def clear_role_error(self): - self.role.setToolTip("Match the role of the context.") - self.role.setPalette(self.orig_palette) + self.clear_criteria_error(self.role, "Match the role of the context.") def set_role(self): try: self.query.role = self.role.text() except Exception as ex: self.log.error("Context role error: {0}".format(ex)) - self.role.setToolTip("Error: " + str(ex)) - self.role.setPalette(self.error_palette) + self.set_criteria_error(self.role, ex) def set_role_regex(self, state): self.log.debug("Setting role_regex {0}".format(state)) @@ -213,16 +208,14 @@ class InitialSIDQueryTab(AnalysisTab): # Type criteria # def clear_type_error(self): - self.type_.setToolTip("Match the type of the context.") - self.type_.setPalette(self.orig_palette) + self.clear_criteria_error(self.type_, "Match the type of the context.") def set_type(self): try: self.query.type_ = self.type_.text() except Exception as ex: self.log.error("Context type error: {0}".format(ex)) - self.type_.setToolTip("Error: " + str(ex)) - self.type_.setPalette(self.error_palette) + self.set_criteria_error(self.type_, ex) def set_type_regex(self, state): self.log.debug("Setting type_regex {0}".format(state)) @@ -234,16 +227,14 @@ class InitialSIDQueryTab(AnalysisTab): # Range criteria # def clear_range_error(self): - self.range_.setToolTip("Match the range of the context.") - self.range_.setPalette(self.orig_palette) + self.clear_criteria_error(self.range_, "Match the range of the context.") def set_range(self): try: self.query.range_ = self.range_.text() except Exception as ex: self.log.info("Context range error: " + str(ex)) - self.range_.setToolTip("Error: " + str(ex)) - self.range_.setPalette(self.error_palette) + self.set_criteria_error(self.range_, ex) # # Save/Load tab diff --git a/setoolsgui/apol/mlsrulequery.py b/setoolsgui/apol/mlsrulequery.py index 086cb56..7619880 100644 --- a/setoolsgui/apol/mlsrulequery.py +++ b/setoolsgui/apol/mlsrulequery.py @@ -63,6 +63,7 @@ class MLSRuleQueryTab(AnalysisTab): self.target.setCompleter(self.typeattr_completion) # setup indications of errors on source/target/default + self.errors = set() self.orig_palette = self.source.palette() self.error_palette = self.source.palette() self.error_palette.setColor(QPalette.Base, Qt.red) @@ -143,16 +144,14 @@ class MLSRuleQueryTab(AnalysisTab): # def clear_source_error(self): - self.source.setToolTip("Match the source type/attribute of the rule.") - self.source.setPalette(self.orig_palette) + self.clear_criteria_error(self.source, "Match the source type/attribute of the rule.") def set_source(self): try: self.query.source = self.source.text() except Exception as ex: self.log.error("Source type/attribute error: {0}".format(ex)) - self.source.setToolTip("Error: {0}".format(ex)) - self.source.setPalette(self.error_palette) + self.set_criteria_error(self.source, ex) def set_source_regex(self, state): self.log.debug("Setting source_regex {0}".format(state)) @@ -165,16 +164,14 @@ class MLSRuleQueryTab(AnalysisTab): # def clear_target_error(self): - self.target.setToolTip("Match the target type/attribute of the rule.") - self.target.setPalette(self.orig_palette) + self.clear_criteria_error(self.target, "Match the target type/attribute of the rule.") def set_target(self): try: self.query.target = self.target.text() except Exception as ex: self.log.error("Target type/attribute error: {0}".format(ex)) - self.target.setToolTip("Error: {0}".format(ex)) - self.target.setPalette(self.error_palette) + self.set_criteria_error(self.target, ex) def set_target_regex(self, state): self.log.debug("Setting target_regex {0}".format(state)) @@ -201,16 +198,14 @@ class MLSRuleQueryTab(AnalysisTab): # def clear_default_error(self): - self.default_range.setToolTip("Match the default type the rule.") - self.default_range.setPalette(self.orig_palette) + self.clear_criteria_error(self.default_range, "Match the default type the rule.") def set_default_range(self): try: self.query.default = self.default_range.text() except Exception as ex: self.log.error("Default range error: {0}".format(ex)) - self.default_range.setToolTip("Error: {0}".format(ex)) - self.default_range.setPalette(self.error_palette) + self.set_criteria_error(self.default_range, ex) # # Save/Load tab diff --git a/setoolsgui/apol/netifconquery.py b/setoolsgui/apol/netifconquery.py index dad7dcd..3d75462 100644 --- a/setoolsgui/apol/netifconquery.py +++ b/setoolsgui/apol/netifconquery.py @@ -76,6 +76,7 @@ class NetifconQueryTab(AnalysisTab): self.type_.setCompleter(self.type_completion) # setup indications of errors on source/target/default + self.errors = set() self.orig_palette = self.type_.palette() self.error_palette = self.type_.palette() self.error_palette.setColor(QPalette.Base, Qt.red) @@ -150,16 +151,14 @@ class NetifconQueryTab(AnalysisTab): # Name criteria # def clear_name_error(self): - self.name.setToolTip("Match the device name.") - self.name.setPalette(self.orig_palette) + self.clear_criteria_error(self.name, "Match the device name.") def set_name(self): try: self.query.name = self.name.text() except Exception as ex: self.log.error("Device name error: {0}".format(ex)) - self.name.setToolTip("Error: " + str(ex)) - self.name.setPalette(self.error_palette) + self.set_criteria_error(self.name, ex) def set_name_regex(self, state): self.log.debug("Setting name_regex {0}".format(state)) @@ -171,16 +170,14 @@ class NetifconQueryTab(AnalysisTab): # User criteria # def clear_user_error(self): - self.user.setToolTip("Match the user of the context.") - self.user.setPalette(self.orig_palette) + self.clear_criteria_error(self.user, "Match the user of the context.") def set_user(self): try: self.query.user = self.user.text() except Exception as ex: self.log.error("Context user error: {0}".format(ex)) - self.user.setToolTip("Error: " + str(ex)) - self.user.setPalette(self.error_palette) + self.set_criteria_error(self.user, ex) def set_user_regex(self, state): self.log.debug("Setting user_regex {0}".format(state)) @@ -192,16 +189,14 @@ class NetifconQueryTab(AnalysisTab): # Role criteria # def clear_role_error(self): - self.role.setToolTip("Match the role of the context.") - self.role.setPalette(self.orig_palette) + self.clear_criteria_error(self.role, "Match the role of the context.") def set_role(self): try: self.query.role = self.role.text() except Exception as ex: self.log.error("Context role error: {0}".format(ex)) - self.role.setToolTip("Error: " + str(ex)) - self.role.setPalette(self.error_palette) + self.set_criteria_error(self.role, ex) def set_role_regex(self, state): self.log.debug("Setting role_regex {0}".format(state)) @@ -213,16 +208,14 @@ class NetifconQueryTab(AnalysisTab): # Type criteria # def clear_type_error(self): - self.type_.setToolTip("Match the type of the context.") - self.type_.setPalette(self.orig_palette) + self.clear_criteria_error(self.type_, "Match the type of the context.") def set_type(self): try: self.query.type_ = self.type_.text() except Exception as ex: self.log.error("Context type error: {0}".format(ex)) - self.type_.setToolTip("Error: " + str(ex)) - self.type_.setPalette(self.error_palette) + self.set_criteria_error(self.type_, ex) def set_type_regex(self, state): self.log.debug("Setting type_regex {0}".format(state)) @@ -234,16 +227,14 @@ class NetifconQueryTab(AnalysisTab): # Range criteria # def clear_range_error(self): - self.range_.setToolTip("Match the range of the context.") - self.range_.setPalette(self.orig_palette) + self.clear_criteria_error(self.range_, "Match the range of the context.") def set_range(self): try: self.query.range_ = self.range_.text() except Exception as ex: self.log.info("Context range error: " + str(ex)) - self.range_.setToolTip("Error: " + str(ex)) - self.range_.setPalette(self.error_palette) + self.set_criteria_error(self.range_, ex) # # Save/Load tab diff --git a/setoolsgui/apol/nodeconquery.py b/setoolsgui/apol/nodeconquery.py index be404e7..e71e128 100644 --- a/setoolsgui/apol/nodeconquery.py +++ b/setoolsgui/apol/nodeconquery.py @@ -79,6 +79,7 @@ class NodeconQueryTab(AnalysisTab): self.type_.setCompleter(self.type_completion) # setup indications of errors on source/target/default + self.errors = set() self.orig_palette = self.type_.palette() self.error_palette = self.type_.palette() self.error_palette.setColor(QPalette.Base, Qt.red) @@ -159,31 +160,27 @@ class NodeconQueryTab(AnalysisTab): # Network criteria # def clear_network_error(self): - self.network.setToolTip("Match the network.") - self.network.setPalette(self.orig_palette) + self.clear_criteria_error(self.network, "Match the network.") def set_network(self): try: self.query.network = self.network.text() except Exception as ex: self.log.error("Network error: {0}".format(ex)) - self.network.setToolTip("Error: " + str(ex)) - self.network.setPalette(self.error_palette) + self.set_criteria_error(self.network, ex) # # User criteria # def clear_user_error(self): - self.user.setToolTip("Match the user of the context.") - self.user.setPalette(self.orig_palette) + self.clear_criteria_error(self.user, "Match the user of the context.") def set_user(self): try: self.query.user = self.user.text() except Exception as ex: self.log.error("Context user error: {0}".format(ex)) - self.user.setToolTip("Error: " + str(ex)) - self.user.setPalette(self.error_palette) + self.set_criteria_error(self.user, ex) def set_user_regex(self, state): self.log.debug("Setting user_regex {0}".format(state)) @@ -195,16 +192,14 @@ class NodeconQueryTab(AnalysisTab): # Role criteria # def clear_role_error(self): - self.role.setToolTip("Match the role of the context.") - self.role.setPalette(self.orig_palette) + self.clear_criteria_error(self.role, "Match the role of the context.") def set_role(self): try: self.query.role = self.role.text() except Exception as ex: self.log.error("Context role error: {0}".format(ex)) - self.role.setToolTip("Error: " + str(ex)) - self.role.setPalette(self.error_palette) + self.set_criteria_error(self.role, ex) def set_role_regex(self, state): self.log.debug("Setting role_regex {0}".format(state)) @@ -216,16 +211,14 @@ class NodeconQueryTab(AnalysisTab): # Type criteria # def clear_type_error(self): - self.type_.setToolTip("Match the type of the context.") - self.type_.setPalette(self.orig_palette) + self.clear_criteria_error(self.type_, "Match the type of the context.") def set_type(self): try: self.query.type_ = self.type_.text() except Exception as ex: self.log.error("Context type error: {0}".format(ex)) - self.type_.setToolTip("Error: " + str(ex)) - self.type_.setPalette(self.error_palette) + self.set_criteria_error(self.type_, ex) def set_type_regex(self, state): self.log.debug("Setting type_regex {0}".format(state)) @@ -237,16 +230,14 @@ class NodeconQueryTab(AnalysisTab): # Range criteria # def clear_range_error(self): - self.range_.setToolTip("Match the range of the context.") - self.range_.setPalette(self.orig_palette) + self.clear_criteria_error(self.range_, "Match the range of the context.") def set_range(self): try: self.query.range_ = self.range_.text() except Exception as ex: self.log.info("Context range error: " + str(ex)) - self.range_.setToolTip("Error: " + str(ex)) - self.range_.setPalette(self.error_palette) + self.set_criteria_error(self.range_, ex) # # Save/Load tab diff --git a/setoolsgui/apol/objclassquery.py b/setoolsgui/apol/objclassquery.py index 2fde3cb..fe4e5b6 100644 --- a/setoolsgui/apol/objclassquery.py +++ b/setoolsgui/apol/objclassquery.py @@ -74,6 +74,7 @@ class ObjClassQueryTab(AnalysisTab): self.table_results.sortByColumn(0, Qt.AscendingOrder) # setup indications of errors on level/range + self.errors = set() self.orig_palette = self.name.palette() self.error_palette = self.name.palette() self.error_palette.setColor(QPalette.Base, Qt.red) @@ -130,16 +131,14 @@ class ObjClassQueryTab(AnalysisTab): # Name criteria # def clear_name_error(self): - self.name.setToolTip("Match the object class name.") - self.name.setPalette(self.orig_palette) + self.clear_criteria_error(self.name, "Match the object class name.") def set_name(self): try: self.query.name = self.name.text() except Exception as ex: self.log.error("Object class name error: {0}".format(ex)) - self.name.setToolTip("Error: " + str(ex)) - self.name.setPalette(self.error_palette) + self.set_criteria_error(self.name, ex) def set_name_regex(self, state): self.log.debug("Setting name_regex {0}".format(state)) diff --git a/setoolsgui/apol/portconquery.py b/setoolsgui/apol/portconquery.py index 272e8df..28f00fa 100644 --- a/setoolsgui/apol/portconquery.py +++ b/setoolsgui/apol/portconquery.py @@ -76,6 +76,7 @@ class PortconQueryTab(AnalysisTab): self.type_.setCompleter(self.type_completion) # setup indications of errors on source/target/default + self.errors = set() self.orig_palette = self.type_.palette() self.error_palette = self.type_.palette() self.error_palette.setColor(QPalette.Base, Qt.red) @@ -148,8 +149,7 @@ class PortconQueryTab(AnalysisTab): # Ports criteria # def clear_ports_error(self): - self.ports.setToolTip("Match the ports.") - self.ports.setPalette(self.orig_palette) + self.clear_criteria_error(self.ports, "Match the ports.") def set_ports(self): try: @@ -171,23 +171,20 @@ class PortconQueryTab(AnalysisTab): except Exception as ex: self.log.error("Ports error: {0}".format(ex)) - self.ports.setToolTip("Error: " + str(ex)) - self.ports.setPalette(self.error_palette) + self.set_criteria_error(self.ports, ex) # # User criteria # def clear_user_error(self): - self.user.setToolTip("Match the user of the context.") - self.user.setPalette(self.orig_palette) + self.clear_criteria_error(self.user, "Match the user of the context.") def set_user(self): try: self.query.user = self.user.text() except Exception as ex: self.log.error("Context user error: {0}".format(ex)) - self.user.setToolTip("Error: " + str(ex)) - self.user.setPalette(self.error_palette) + self.set_criteria_error(self.user, ex) def set_user_regex(self, state): self.log.debug("Setting user_regex {0}".format(state)) @@ -199,16 +196,14 @@ class PortconQueryTab(AnalysisTab): # Role criteria # def clear_role_error(self): - self.role.setToolTip("Match the role of the context.") - self.role.setPalette(self.orig_palette) + self.clear_criteria_error(self.role, "Match the role of the context.") def set_role(self): try: self.query.role = self.role.text() except Exception as ex: self.log.error("Context role error: {0}".format(ex)) - self.role.setToolTip("Error: " + str(ex)) - self.role.setPalette(self.error_palette) + self.set_criteria_error(self.role, ex) def set_role_regex(self, state): self.log.debug("Setting role_regex {0}".format(state)) @@ -220,16 +215,14 @@ class PortconQueryTab(AnalysisTab): # Type criteria # def clear_type_error(self): - self.type_.setToolTip("Match the type of the context.") - self.type_.setPalette(self.orig_palette) + self.clear_criteria_error(self.type_, "Match the type of the context.") def set_type(self): try: self.query.type_ = self.type_.text() except Exception as ex: self.log.error("Context type error: {0}".format(ex)) - self.type_.setToolTip("Error: " + str(ex)) - self.type_.setPalette(self.error_palette) + self.set_criteria_error(self.type_, ex) def set_type_regex(self, state): self.log.debug("Setting type_regex {0}".format(state)) @@ -241,16 +234,14 @@ class PortconQueryTab(AnalysisTab): # Range criteria # def clear_range_error(self): - self.range_.setToolTip("Match the range of the context.") - self.range_.setPalette(self.orig_palette) + self.clear_criteria_error(self.range_, "Match the range of the context.") def set_range(self): try: self.query.range_ = self.range_.text() except Exception as ex: self.log.info("Context range error: " + str(ex)) - self.range_.setToolTip("Error: " + str(ex)) - self.range_.setPalette(self.error_palette) + self.set_criteria_error(self.range_, ex) # # Save/Load tab diff --git a/setoolsgui/apol/rbacrulequery.py b/setoolsgui/apol/rbacrulequery.py index f913540..f7698bb 100644 --- a/setoolsgui/apol/rbacrulequery.py +++ b/setoolsgui/apol/rbacrulequery.py @@ -73,6 +73,7 @@ class RBACRuleQueryTab(AnalysisTab): self.target.setCompleter(self.roletype_completion) # setup indications of errors on source/target/default + self.errors = set() self.orig_palette = self.source.palette() self.error_palette = self.source.palette() self.error_palette.setColor(QPalette.Base, Qt.red) @@ -156,16 +157,14 @@ class RBACRuleQueryTab(AnalysisTab): # def clear_source_error(self): - self.source.setToolTip("Match the source role of the rule.") - self.source.setPalette(self.orig_palette) + self.clear_criteria_error(self.source, "Match the source role of the rule.") def set_source(self): try: self.query.source = self.source.text() except Exception as ex: self.log.error("Source role error: {0}".format(ex)) - self.source.setToolTip("Error: " + str(ex)) - self.source.setPalette(self.error_palette) + self.set_criteria_error(self.source, ex) def set_source_regex(self, state): self.log.debug("Setting source_regex {0}".format(state)) @@ -178,16 +177,14 @@ class RBACRuleQueryTab(AnalysisTab): # def clear_target_error(self): - self.target.setToolTip("Match the target role/type of the rule.") - self.target.setPalette(self.orig_palette) + self.clear_criteria_error(self.target, "Match the target role/type of the rule.") def set_target(self): try: self.query.target = self.target.text() except Exception as ex: self.log.error("Target type/role error: {0}".format(ex)) - self.target.setToolTip("Error: " + str(ex)) - self.target.setPalette(self.error_palette) + self.set_criteria_error(self.target, ex) def set_target_regex(self, state): self.log.debug("Setting target_regex {0}".format(state)) @@ -214,8 +211,7 @@ class RBACRuleQueryTab(AnalysisTab): # def clear_default_error(self): - self.default_role.setToolTip("Match the default role the rule.") - self.default_role.setPalette(self.orig_palette) + self.clear_criteria_error(self.default_role, "Match the default role the rule.") def set_default_role(self): self.query.default_regex = self.default_regex.isChecked() @@ -224,8 +220,7 @@ class RBACRuleQueryTab(AnalysisTab): self.query.default = self.default_role.text() except Exception as ex: self.log.error("Default role error: {0}".format(ex)) - self.default_role.setToolTip("Error: " + str(ex)) - self.default_role.setPalette(self.error_palette) + self.set_criteria_error(self.default_role, ex) def set_default_regex(self, state): self.log.debug("Setting default_regex {0}".format(state)) diff --git a/setoolsgui/apol/rolequery.py b/setoolsgui/apol/rolequery.py index d07c9e2..d5f3794 100644 --- a/setoolsgui/apol/rolequery.py +++ b/setoolsgui/apol/rolequery.py @@ -70,6 +70,7 @@ class RoleQueryTab(AnalysisTab): self.table_results.sortByColumn(0, Qt.AscendingOrder) # setup indications of errors on level/range + self.errors = set() self.orig_palette = self.name.palette() self.error_palette = self.name.palette() self.error_palette.setColor(QPalette.Base, Qt.red) @@ -125,16 +126,14 @@ class RoleQueryTab(AnalysisTab): # Name criteria # def clear_name_error(self): - self.name.setToolTip("Match the role name.") - self.name.setPalette(self.orig_palette) + self.clear_criteria_error(self.name, "Match the role name.") def set_name(self): try: self.query.name = self.name.text() except Exception as ex: self.log.error("Role name error: {0}".format(ex)) - self.name.setToolTip("Error: " + str(ex)) - self.name.setPalette(self.error_palette) + self.set_criteria_error(self.name, ex) def set_name_regex(self, state): self.log.debug("Setting name_regex {0}".format(state)) diff --git a/setoolsgui/apol/sensitivityquery.py b/setoolsgui/apol/sensitivityquery.py index 76e54f6..faffc1d 100644 --- a/setoolsgui/apol/sensitivityquery.py +++ b/setoolsgui/apol/sensitivityquery.py @@ -65,6 +65,7 @@ class SensitivityQueryTab(AnalysisTab): self.table_results.sortByColumn(0, Qt.AscendingOrder) # setup indications of errors on level/range + self.errors = set() self.orig_palette = self.name.palette() self.error_palette = self.name.palette() self.error_palette.setColor(QPalette.Base, Qt.red) @@ -118,16 +119,14 @@ class SensitivityQueryTab(AnalysisTab): # Name criteria # def clear_name_error(self): - self.name.setToolTip("Match the sensitivity name.") - self.name.setPalette(self.orig_palette) + self.clear_criteria_error(self.name, "Match the sensitivity name.") def set_name(self): try: self.query.name = self.name.text() except Exception as ex: self.log.error("Sensitivity name error: {0}".format(ex)) - self.name.setToolTip("Error: " + str(ex)) - self.name.setPalette(self.error_palette) + self.set_criteria_error(self.name, ex) def set_name_regex(self, state): self.log.debug("Setting name_regex {0}".format(state)) diff --git a/setoolsgui/apol/terulequery.py b/setoolsgui/apol/terulequery.py index 839b930..87fbb1d 100644 --- a/setoolsgui/apol/terulequery.py +++ b/setoolsgui/apol/terulequery.py @@ -71,6 +71,7 @@ class TERuleQueryTab(AnalysisTab): self.default_type.setCompleter(self.type_completion) # setup indications of errors on source/target/default + self.errors = set() self.orig_palette = self.source.palette() self.error_palette = self.source.palette() self.error_palette.setColor(QPalette.Base, Qt.red) @@ -183,16 +184,14 @@ class TERuleQueryTab(AnalysisTab): # def clear_source_error(self): - self.source.setToolTip("Match the source type/attribute of the rule.") - self.source.setPalette(self.orig_palette) + self.clear_criteria_error(self.source, "Match the source type/attribute of the rule.") def set_source(self): try: self.query.source = self.source.text() except Exception as ex: self.log.error("Source type/attribute error: {0}".format(ex)) - self.source.setToolTip("Error: " + str(ex)) - self.source.setPalette(self.error_palette) + self.set_criteria_error(self.source, ex) def set_source_regex(self, state): self.log.debug("Setting source_regex {0}".format(state)) @@ -205,16 +204,14 @@ class TERuleQueryTab(AnalysisTab): # def clear_target_error(self): - self.target.setToolTip("Match the target type/attribute of the rule.") - self.target.setPalette(self.orig_palette) + self.clear_criteria_error(self.target, "Match the target type/attribute of the rule.") def set_target(self): try: self.query.target = self.target.text() except Exception as ex: self.log.error("Target type/attribute error: {0}".format(ex)) - self.target.setToolTip("Error: " + str(ex)) - self.target.setPalette(self.error_palette) + self.set_criteria_error(self.target, ex) def set_target_regex(self, state): self.log.debug("Setting target_regex {0}".format(state)) @@ -264,9 +261,9 @@ class TERuleQueryTab(AnalysisTab): self.xperms_equal.setEnabled(mode) def clear_xperm_error(self): - self.xperms.setToolTip("Match the extended permissions of the rule. Comma-separated " - "permissions or ranges of permissions.") - self.xperms.setPalette(self.orig_palette) + self.clear_criteria_error(self.xperms, + "Match the extended permissions of the rule. " + "Comma-separated permissions or ranges of permissions.") def set_xperm(self): xperms = [] @@ -290,16 +287,14 @@ class TERuleQueryTab(AnalysisTab): except Exception as ex: self.log.error("Extended permissions error: {0}".format(ex)) - self.xperms.setToolTip("Error: " + str(ex)) - self.xperms.setPalette(self.error_palette) + self.set_criteria_error(self.xperms, ex) # # Default criteria # def clear_default_error(self): - self.default_type.setToolTip("Match the default type the rule.") - self.default_type.setPalette(self.orig_palette) + self.clear_criteria_error(self.default_type, "Match the default type the rule.") def set_default_type(self): self.query.default_regex = self.default_regex.isChecked() @@ -308,8 +303,7 @@ class TERuleQueryTab(AnalysisTab): self.query.default = self.default_type.text() except Exception as ex: self.log.error("Default type error: {0}".format(ex)) - self.default_type.setToolTip("Error: " + str(ex)) - self.default_type.setPalette(self.error_palette) + self.set_criteria_error(self.default_type, ex) def set_default_regex(self, state): self.log.debug("Setting default_regex {0}".format(state)) diff --git a/setoolsgui/apol/typeattrquery.py b/setoolsgui/apol/typeattrquery.py index 88070ee..031107e 100644 --- a/setoolsgui/apol/typeattrquery.py +++ b/setoolsgui/apol/typeattrquery.py @@ -70,6 +70,7 @@ class TypeAttributeQueryTab(AnalysisTab): self.table_results.sortByColumn(0, Qt.AscendingOrder) # setup indications of errors on level/range + self.errors = set() self.orig_palette = self.name.palette() self.error_palette = self.name.palette() self.error_palette.setColor(QPalette.Base, Qt.red) @@ -125,16 +126,14 @@ class TypeAttributeQueryTab(AnalysisTab): # Name criteria # def clear_name_error(self): - self.name.setToolTip("Match the attribute name.") - self.name.setPalette(self.orig_palette) + self.clear_criteria_error(self.name, "Match the attribute name.") def set_name(self): try: self.query.name = self.name.text() except Exception as ex: self.log.error("Type attribute name error: {0}".format(ex)) - self.name.setToolTip("Error: " + str(ex)) - self.name.setPalette(self.error_palette) + self.set_criteria_error(self.name, ex) def set_name_regex(self, state): self.log.debug("Setting name_regex {0}".format(state)) diff --git a/setoolsgui/apol/typequery.py b/setoolsgui/apol/typequery.py index 96b2b2a..0e72587 100644 --- a/setoolsgui/apol/typequery.py +++ b/setoolsgui/apol/typequery.py @@ -70,6 +70,7 @@ class TypeQueryTab(AnalysisTab): self.table_results.sortByColumn(0, Qt.AscendingOrder) # setup indications of errors on level/range + self.errors = set() self.orig_palette = self.name.palette() self.error_palette = self.name.palette() self.error_palette.setColor(QPalette.Base, Qt.red) @@ -125,16 +126,14 @@ class TypeQueryTab(AnalysisTab): # Name criteria # def clear_name_error(self): - self.name.setToolTip("Match the type name.") - self.name.setPalette(self.orig_palette) + self.clear_criteria_error(self.name, "Match the type name.") def set_name(self): try: self.query.name = self.name.text() except Exception as ex: self.log.error("Type name error: {0}".format(ex)) - self.name.setToolTip("Error: " + str(ex)) - self.name.setPalette(self.error_palette) + self.set_criteria_error(self.name, ex) def set_name_regex(self, state): self.log.debug("Setting name_regex {0}".format(state)) diff --git a/setoolsgui/apol/userquery.py b/setoolsgui/apol/userquery.py index 86c198f..03b9432 100644 --- a/setoolsgui/apol/userquery.py +++ b/setoolsgui/apol/userquery.py @@ -70,6 +70,7 @@ class UserQueryTab(AnalysisTab): self.table_results.sortByColumn(0, Qt.AscendingOrder) # setup indications of errors on level/range + self.errors = set() self.orig_palette = self.name.palette() self.error_palette = self.name.palette() self.error_palette.setColor(QPalette.Base, Qt.red) @@ -148,16 +149,14 @@ class UserQueryTab(AnalysisTab): # Name criteria # def clear_name_error(self): - self.name.setToolTip("Match the user name.") - self.name.setPalette(self.orig_palette) + self.clear_criteria_error(self.name, "Match the user name.") def set_name(self): try: self.query.name = self.name.text() except Exception as ex: self.log.error("User name error: {0}".format(ex)) - self.name.setToolTip("Error: " + str(ex)) - self.name.setPalette(self.error_palette) + self.set_criteria_error(self.name, ex) def set_name_regex(self, state): self.log.debug("Setting name_regex {0}".format(state)) @@ -182,31 +181,27 @@ class UserQueryTab(AnalysisTab): # Default level criteria # def clear_level_error(self): - self.level.setToolTip("Match the default level of the user.") - self.level.setPalette(self.orig_palette) + self.clear_criteria_error(self.level, "Match the default level of the user.") def set_level(self): try: self.query.level = self.level.text() except Exception as ex: self.log.info("Level criterion error: " + str(ex)) - self.level.setToolTip("Error: " + str(ex)) - self.level.setPalette(self.error_palette) + self.set_criteria_error(self.level, ex) # # Range criteria # def clear_range_error(self): - self.range_.setToolTip("Match the default range of the user.") - self.range_.setPalette(self.orig_palette) + self.clear_criteria_error(self.range_, "Match the default range of the user.") def set_range(self): try: self.query.range_ = self.range_.text() except Exception as ex: self.log.info("Range criterion error: " + str(ex)) - self.range_.setToolTip("Error: " + str(ex)) - self.range_.setPalette(self.error_palette) + self.set_criteria_error(self.range_, ex) # # Save/Load tab