def onSubWindowActivated(self, subwindow): """ Executed when the active subwindow changes. :type subwindow: MdiSubWindow """ if subwindow and isinstance(subwindow, BlackBirdMdiSubWindow): if self.diagram: # If the info widget is currently inspecting a # diagram, detach signals from the subwindow which # is going out of focus, before connecting new ones. LOGGER.debug('Disconnecting from diagram: %s', self.diagram.name) disconnect(self.diagram.selectionChanged, self.onDiagramSelectionChanged) # disconnect(self.diagram.sgnUpdated, self.onDiagramUpdated) # Attach the new view/diagram to the info widget. LOGGER.debug('Connecting to diagram: %s', subwindow.diagram.name) connect(subwindow.diagram.selectionChanged, self.onDiagramSelectionChanged) # connect(subwindow.diagram.sgnUpdated, self.onDiagramUpdated) self.setDiagram(subwindow.diagram) self.stack(self.diagram) else: if not self.session.mdi.subWindowList(): # If we don't have any active subwindow (which means that # they have been all closed and not just out of focus) we # detach the widget from the last inspected diagram. if self.diagram: LOGGER.debug('Disconnecting from diagram: %s', self.diagram.name) disconnect(self.diagram.selectionChanged, self.onDiagramSelectionChanged) # disconnect(self.diagram.sgnUpdated, self.onDiagramUpdated) self.setDiagram(None)
def disconnectIRISignals(self): disconnect(self.iri.sgnIRIModified, self.onIRIModified) disconnect(self.iri.sgnIRIPropModified, self.onIRIPropModified) disconnect(self.iri.sgnAnnotationAdded, self.onAnnotationAdded) disconnect(self.iri.sgnAnnotationRemoved, self.onAnnotationRemoved) disconnect(self.iri.sgnAnnotationModified, self.onAnnotationModified) self.disconnectIRIMetaSignals()
def dispose(self): """ Executed whenever the plugin is going to be destroyed. """ # DISCONNECT FROM CURRENT PROJECT widget = self.widget('ontology_explorer') self.debug('Disconnecting from project: %s', self.project.name) disconnect(self.project.sgnItemAdded, widget.doAddNode) disconnect(self.project.sgnItemRemoved, widget.doRemoveNode) disconnect(self.project.sgnMetaAdded, widget.onMetaUpdated) disconnect(self.project.sgnMetaRemoved, widget.onMetaUpdated) # DISCONNECT FROM ACTIVE SESSION self.debug('Disconnecting from active session') disconnect(self.session.sgnReady, self.onSessionReady) # REMOVE DOCKING AREA WIDGET MENU ENTRY self.debug('Removing docking area widget toggle from "view" menu') menu = self.session.menu('view') menu.removeAction( self.widget('ontology_explorer_dock').toggleViewAction()) # UNINSTALL THE PALETTE DOCK WIDGET self.debug('Uninstalling docking area widget') self.session.removeDockWidget(self.widget('ontology_explorer_dock'))
def UpdateTableForIRI(self, iri_inp, nodes_inp, diag_name): disconnect(self.table.cellChanged, self.cell_changed) self.FillTableWithIRIPrefixNodesDictionaryKeysAndValues() connect(self.table.cellChanged, self.cell_changed)
def onDiagramRemoved(self, diagram): """ Executed when a diagram is removed to the project. :typw diagram: Diagram """ self.debug('Disconnecting from diagram: %s', diagram.name) disconnect(diagram.sgnItemInsertionCompleted, self.onDiagramItemInsertionCompleted) disconnect(diagram.sgnModeChanged, self.onDiagramModeChanged)
def stopMove(self): """ Stop the view movement by destroying the timer object causing it. """ if self.mv_Timer: self.mv_Timer.stop() disconnect(self.mv_Timer.timeout) self.mv_Timer = None
def entry_NOT_OK(self, iri, prefixes, message): self.ENTRY_IGNORE_var.add(True) self.session.statusBar().showMessage(message, 10000) disconnect(self.table.cellChanged, self.cell_changed) self.FillTableWithIRIPrefixNodesDictionaryKeysAndValues() connect(self.table.cellChanged, self.cell_changed)
def onUnsatisfiableEntities(self): """ Executed when the consistency check detects unsatisfiable entities in the ontology. """ # CONNECT TO PROJECT SPECIFIC SIGNALS widget = self.widget('unsatisfiable_entity_explorer') connect(self.project.sgnItemAdded, widget.doAddNode) connect(self.project.sgnItemRemoved, widget.doRemoveNode) # FILL IN UNSATISFIABLE ENTITIES EXPLORER WITH DATA connect(self.sgnFakeItemAdded, widget.doAddNode) connect(self.sgnFakeExplanationAdded, widget.doAddExplanation) classes_only_unsatisfiable_nodes_in_diagram = \ self.get_list_of_nodes_in_diagram_from_OWL_terms(self.project.unsatisfiable_classes) attributes_only_unsatisfiable_nodes_in_diagram = \ self.get_list_of_nodes_in_diagram_from_OWL_terms(self.project.unsatisfiable_attributes) roles_only_unsatisfiable_nodes_in_diagram = \ self.get_list_of_nodes_in_diagram_from_OWL_terms(self.project.unsatisfiable_roles) for n in classes_only_unsatisfiable_nodes_in_diagram: self.project.nodes_of_unsatisfiable_entities.extend(n) for n in attributes_only_unsatisfiable_nodes_in_diagram: self.project.nodes_of_unsatisfiable_entities.extend(n) for n in roles_only_unsatisfiable_nodes_in_diagram: self.project.nodes_of_unsatisfiable_entities.extend(n) temp = [] for n in self.project.nodes_of_unsatisfiable_entities: owl_term = self.project.getOWLtermfornode(n) temp.append(owl_term) self.project.nodes_of_unsatisfiable_entities.extend(temp) self.add_unsatisfiable_nodes_in_widget( classes_only_unsatisfiable_nodes_in_diagram, 'unsatisfiable_classes') self.add_unsatisfiable_nodes_in_widget( attributes_only_unsatisfiable_nodes_in_diagram, 'unsatisfiable_attributes') self.add_unsatisfiable_nodes_in_widget( roles_only_unsatisfiable_nodes_in_diagram, 'unsatisfiable_roles') disconnect(self.sgnFakeItemAdded, widget.doAddNode) disconnect(self.sgnFakeExplanationAdded, widget.doAddExplanation) # SHOW THE PLUGIN DOCK WIDGET if not self.widget('unsatisfiable_entity_explorer_dock').isVisible(): self.widget('unsatisfiable_entity_explorer_dock').toggleViewAction( ).trigger() self.widget('unsatisfiable_entity_explorer_dock').raise_()
def onSubWindowActivated(self, subwindow): """ Executed when the active subwindow changes. :type subwindow: MdiSubWindow """ if subwindow: if self.view: # If the Zoom control widgets are currently controlling a diagram view, # disconnect them from the old view before connecting them to the new one. self.debug('Disconnecting from diagram: %s', self.view.diagram.name) disconnect(self.sgnChanged, self.view.onZoomChanged) disconnect(self.view.sgnScaled, self.onScaleChanged) # Attach the new view to the Zoom controls. self.debug('Connecting to diagram: %s', subwindow.diagram.name) connect(self.sgnChanged, subwindow.view.onZoomChanged) connect(subwindow.view.sgnScaled, self.onScaleChanged) self.adjust(subwindow.view.zoom) self.setView(subwindow.view) else: if not self.session.mdi.subWindowList(): if self.view: # If the Zoom control widgets are currently controlling a diagram view, # disconnect them from the old view before connecting them to the new one. self.debug('Disconnecting from diagram: %s', self.view.diagram.name) disconnect(self.sgnChanged, self.view.onZoomChanged) disconnect(self.view.sgnScaled, self.onScaleChanged) self.setLevel(DiagramView.ZoomDefault) self.setView(None)
def onSessionReady(self): """ Executed whenever the main session completes the startup sequence. """ # CONNECT TO PROJECT SPECIFIC SIGNALS widget = self.widget('ontology_explorer') self.debug('Connecting to project: %s', self.project.name) connect(self.project.sgnItemAdded, widget.doAddNode) connect(self.project.sgnItemRemoved, widget.doRemoveNode) # FILL IN ONTOLOGY EXPLORER WITH DATA connect(self.sgnFakeItemAdded, widget.doAddNode) for node in self.project.nodes(): self.sgnFakeItemAdded.emit(node.diagram, node) disconnect(self.sgnFakeItemAdded, widget.doAddNode)
def setProject(self, project): """ Set the project explorer to browse the given project. :type project: Project """ self.model.clear() self.model.appendRow(self.root) self.root.setText(project.name) connect(self.sgnFakeDiagramAdded, self.doAddDiagram) for diagram in project.diagrams(): self.sgnFakeDiagramAdded.emit(diagram) disconnect(self.sgnFakeDiagramAdded) sindex = self.root.index() pindex = self.proxy.mapFromSource(sindex) self.projectview.expand(pindex)
def disconnectIRISignals(self, iri): """ :type iri: IRI """ disconnect(iri.sgnAnnotationAdded, self.onIRIAnnotationAssertionAdded) disconnect(iri.sgnAnnotationRemoved, self.onIRIAnnotationAssertionRemoved) disconnect(iri.sgnAnnotationModified, self.onIRIAnnotationAssertionModified) disconnect(iri.sgnIRIModified, self.onIRIModified)
def dispose(self): """ Executed whenever the plugin is going to be destroyed. """ # DISCONNECT FROM ACTIVE SESSION self.debug('Disconnecting from active session') disconnect(self.session.sgnReady, self.onSessionReady) disconnect(self.session.mdi.subWindowActivated, self.onSubWindowActivated) # REMOVE DOCKING AREA WIDGET MENU ENTRY self.debug('Removing docking area widget toggle from "view" menu') menu = self.session.menu('view') menu.removeAction(self.widget('iri_dock').toggleViewAction()) # UNINSTALL THE PALETTE DOCK WIDGET self.debug('Uninstalling docking area widget') self.session.removeDockWidget(self.widget('iri_dock'))
def mergeDiagrams(self): """ Perform the merge of the diagrams by importing all the diagrams in the 'other' project in the loaded one. """ for diagram in self.other.diagrams(): # We may be in the situation in which we are importing a diagram with name 'X' # even though we already have a diagram 'X' in our project. Because we do not # want to overwrite diagrams, we perform a rename of the diagram being imported, # to be sure to have a unique diagram name, in the current project namespace. occurrence = 1 name = diagram.name while self.project.diagram(diagram.name): diagram.name = '{0}_{1}'.format(name, occurrence) occurrence += 1 ## SWITCH SIGNAL SLOTS disconnect(diagram.sgnItemAdded, self.other.doAddItem) disconnect(diagram.sgnItemRemoved, self.other.doRemoveItem) connect(diagram.sgnItemAdded, self.project.doAddItem) connect(diagram.sgnItemRemoved, self.project.doRemoveItem) ## MERGE THE DIAGRAM IN THE CURRENT PROJECT self.commands.append(CommandDiagramAdd(diagram, self.project))
def dispose(self): """ Executed whenever the plugin is going to be destroyed. """ # DISCONNECT FROM THE ACTIVE DIAGRAM widget = self.widget('overview') if widget.view(): self.debug('Disconnecting from diagram: %s', widget.diagram.name) disconnect(widget.diagram.selectionChanged, self.onDiagramSelectionChanged) disconnect(widget.diagram.sgnUpdated, self.onDiagramUpdated) # DISCONNECT FROM ACTIVE SESSION self.debug('Disconnecting to active session') disconnect(self.session.mdi.subWindowActivated, self.onSubWindowActivated) # REMOVE DOCKING AREA WIDGET MENU ENTRY self.debug('Removing docking area widget toggle from "view" menu') menu = self.session.menu('view') menu.removeAction(self.widget('overview_dock').toggleViewAction()) # UNINSTALL THE PALETTE DOCK WIDGET self.debug('Uninstalling docking area widget') self.widget('overview_dock').removeEventFilter(self) self.session.removeDockWidget(self.widget('overview_dock'))
def onSessionReady(self): """ Executed whenever the main session completes the startup sequence. """ # CONNECT TO PROJECT SPECIFIC SIGNALS widget = self.widget('ontology_explorer') self.debug('Connecting to project: %s', self.project.name) connect(self.project.sgnItemAdded, widget.doAddNode) connect(self.project.sgnImportedOntologyAdded, widget.onImportedOntologyAdded) connect(self.project.sgnImportedOntologyLoaded, widget.onImportedOntologyAdded) connect(self.project.sgnItemRemoved, widget.doRemoveNode) connect(self.project.sgnImportedOntologyRemoved, widget.onImportedOntologyRemoved) #connect(self.project.sgnUpdated, widget.doResetReasonerHighlight) connect(self.session.sgnUnsatisfiableClass, widget.onUnsatisfiableClass) connect(self.session.sgnUnsatisfiableObjectProperty, widget.onUnsatisfiableObjectProperty) connect(self.session.sgnUnsatisfiableDataProperty, widget.onUnsatisfiableDataProperty) connect(self.session.sgnConsistencyCheckReset, widget.doResetReasonerHighlight) # FILL IN ONTOLOGY EXPLORER WITH DATA connect(self.sgnFakeImportedOntologyAdded, widget.onImportedOntologyAdded) for impOnt in self.project.importedOntologies: self.sgnFakeImportedOntologyAdded.emit(impOnt) connect(self.sgnFakeItemAdded, widget.doAddNode) for node in self.project.nodes(): self.sgnFakeItemAdded.emit(node.diagram, node) widget.doFilterItem('') disconnect(self.sgnFakeItemAdded, widget.doAddNode) disconnect(self.sgnFakeImportedOntologyAdded, widget.onImportedOntologyAdded)
def undo(self): if self.add_item_to_IRI_prefixes_nodes_dict is True: disconnect(self.project.sgnItemAdded, self.project.add_item_to_IRI_prefixes_nodes_dict) if self.remove_item_from_IRI_prefixes_nodes_dict is True: disconnect(self.project.sgnItemRemoved, self.project.remove_item_from_IRI_prefixes_nodes_dict) if self.regenerate_label_of_nodes_for_iri is True: disconnect(self.project.sgnIRIPrefixNodeDictionaryUpdated, self.project.regenerate_label_of_nodes_for_iri)
def dispose(self): """ Executed whenever the plugin is going to be destroyed. """ # DISCONNECT FROM THE ACTIVE DIAGRAM if self.view: self.debug('Disconnecting from diagram: %s', self.view.diagram.name) disconnect(self.sgnChanged, self.view.onZoomChanged) disconnect(self.view.sgnScaled, self.onScaleChanged) # DISCONNECT FROM ACTIVE SESSION self.debug('Disconnecting to active session') disconnect(self.session.mdi.subWindowActivated, self.onSubWindowActivated) disconnect(self.session.sgnUpdateState, self.doUpdateState) # UNINSTALL THE PALETTE DOCK WIDGET self.debug('Uninstalling zoom controls from "view" toolbar') for action in self.afwset: self.session.widget('view_toolbar').removeAction(action)
def onSubWindowActivated(self, subwindow): """ Executed when the active subwindow changes. :type subwindow: MdiSubWindow """ if subwindow: # If we have an active subwindow, we change the overview # widget to browse the diagram within such subwindow. widget = self.widget('overview') if widget.view(): # If the overview widget is currently inspecting a # diagram, detach signals from the subwindow which # is going out of focus, before connecting new ones. self.debug('Disconnecting from diagram: %s', widget.diagram.name) disconnect(widget.diagram.selectionChanged, self.onDiagramSelectionChanged) disconnect(widget.diagram.sgnUpdated, self.onDiagramUpdated) # Attach the new view/diagram to the overview widget. self.debug('Connecting to diagram: %s', subwindow.diagram.name) connect(subwindow.diagram.selectionChanged, self.onDiagramSelectionChanged) connect(subwindow.diagram.sgnUpdated, self.onDiagramUpdated) widget.setScene(subwindow.diagram) widget.setView(subwindow.view) widget.redraw() else: if not self.session.mdi.subWindowList(): # If we don't have any active subwindow (which means that # they have been all closed and not just out of focus) we # detach the widget from the last inspected diagram. widget = self.widget('overview') if widget.view(): self.debug('Disconnecting from diagram: %s', widget.diagram.name) disconnect(widget.diagram.selectionChanged, self.onDiagramSelectionChanged) disconnect(widget.diagram.sgnUpdated, self.onDiagramUpdated) widget.setScene(None) widget.setView(None) widget.redraw()
def dispose(self): """ Executed whenever the plugin is going to be destroyed. """ # DISCONNECT FROM CURRENT PROJECT widget = self.widget('ontology_explorer') self.debug('Disconnecting from project: %s', self.project.name) disconnect(self.project.sgnItemAdded, widget.doAddNode) disconnect(self.project.sgnItemRemoved, widget.doRemoveNode) # DISCONNECT FROM ACTIVE SESSION self.debug('Disconnecting from active session') disconnect(self.session.sgnReady, self.onSessionReady) # REMOVE DOCKING AREA WIDGET MENU ENTRY self.debug('Removing docking area widget toggle from "view" menu') menu = self.session.menu('view') menu.removeAction(self.widget('ontology_explorer_dock').toggleViewAction()) # UNINSTALL THE PALETTE DOCK WIDGET self.debug('Uninstalling docking area widget') self.session.removeDockWidget(self.widget('ontology_explorer_dock'))
def dispose(self): """ Executed whenever the plugin is going to be destroyed. """ # DISCONNECT FROM THE ACTIVE DIAGRAM widget = self.widget('overview') if widget.view(): self.debug('Disconnecting from diagram: %s', widget.diagram.name) disconnect(widget.diagram.selectionChanged, self.onDiagramSelectionChanged) disconnect(widget.diagram.sgnUpdated, self.onDiagramUpdated) # DISCONNECT FROM ACTIVE SESSION self.debug('Disconnecting to active session') disconnect(self.session.mdi.subWindowActivated, self.onSubWindowActivated) # REMOVE DOCKING AREA WIDGET MENU ENTRY self.debug('Removing docking area widget toggle from "view" menu') menu = self.session.menu('view') menu.removeAction(self.widget('overview_dock').toggleViewAction()) # UNINSTALL THE PALETTE DOCK WIDGET self.debug('Uninstalling docking area widget') self.session.removeDockWidget(self.widget('overview_dock'))
def onSessionReady(self): """ Executed whenever the main session completes the startup sequence. """ # CONNECT TO PROJECT SPECIFIC SIGNALS widget = self.widget('Unsatisfiable_Entity_Explorer') self.debug('Connecting to project: %s', self.project.name) connect(self.project.sgnItemAdded, widget.doAddNode) connect(self.project.sgnItemRemoved, widget.doRemoveNode) # FILL IN UnsatisfiableEntitiesExplorer WITH DATA connect(self.sgnFakeItemAdded, widget.doAddNode) connect(self.sgnFakeExplanationAdded, widget.doAddExplanation) #print('self.project.unsatisfiable_classes',self.project.unsatisfiable_classes) #print('self.project.unsatisfiable_attributes',self.project.unsatisfiable_attributes) #print('self.project.unsatisfiable_roles',self.project.unsatisfiable_roles) classes_only_unsatisfiable_nodes_in_diagram = self.get_list_of_nodes_in_diagram_from_OWL_terms( self.project.unsatisfiable_classes) attributes_only_unsatisfiable_nodes_in_diagram = self.get_list_of_nodes_in_diagram_from_OWL_terms( self.project.unsatisfiable_attributes) roles_only_unsatisfiable_nodes_in_diagram = self.get_list_of_nodes_in_diagram_from_OWL_terms( self.project.unsatisfiable_roles) #print('classes_only_unsatisfiable_nodes_in_diagram',classes_only_unsatisfiable_nodes_in_diagram) #print('attributes_only_unsatisfiable_nodes_in_diagram',attributes_only_unsatisfiable_nodes_in_diagram) #print('roles_only_unsatisfiable_nodes_in_diagram',roles_only_unsatisfiable_nodes_in_diagram) [ self.project.nodes_of_unsatisfiable_entities.extend(n) for n in classes_only_unsatisfiable_nodes_in_diagram ] [ self.project.nodes_of_unsatisfiable_entities.extend(n) for n in attributes_only_unsatisfiable_nodes_in_diagram ] [ self.project.nodes_of_unsatisfiable_entities.extend(n) for n in roles_only_unsatisfiable_nodes_in_diagram ] temp = [] for n in self.project.nodes_of_unsatisfiable_entities: owl_term = self.project.getOWLtermfornode(n) temp.append(owl_term) """ sub_string = str(n).split(':') str_to_append = str(n).replace(sub_string[0]+':', '') str_to_append = str_to_append.replace(':'+sub_string[len(sub_string)-1], '') temp.append(str_to_append) """ self.project.nodes_of_unsatisfiable_entities.extend(temp) self.add_unsatisfiable_nodes_in_widget( classes_only_unsatisfiable_nodes_in_diagram, 'unsatisfiable_classes') self.add_unsatisfiable_nodes_in_widget( attributes_only_unsatisfiable_nodes_in_diagram, 'unsatisfiable_attributes') self.add_unsatisfiable_nodes_in_widget( roles_only_unsatisfiable_nodes_in_diagram, 'unsatisfiable_roles') disconnect(self.sgnFakeItemAdded, widget.doAddNode) disconnect(self.sgnFakeExplanationAdded, widget.doAddExplanation)
def disconnectSignals(self): disconnect(self.project.sgnPrefixAdded, self.onPrefixAdded) disconnect(self.project.sgnPrefixRemoved, self.onPrefixRemoved) disconnect(self.project.sgnPrefixModified, self.onPrefixModified) #disconnect(self.session.sgnRenderingModified, self.onRenderingModified) self.disconnectIRISignals()
def onSessionReady(self): """ Executed whenever the main session completes the startup sequence. """ # CONNECT TO PROJECT SPECIFIC SIGNALS widget = self.widget('Explanation_explorer') self.debug('Connecting to project: %s', self.project.name) # FILL IN Explanation EXPLORER WITH DATA connect(self.sgnFakeExplanationAdded, widget.doAddExplanation) connect(self.sgnFakeAxiomAdded, widget.doAddAxiom) connect(self.sgnFakeItemAdded, widget.doAddNodeOREdge) if len(self.project.explanations_for_inconsistent_ontology ) > 0 and len( self.project.explanations_for_unsatisfiable_classes) > 0: LOGGER.error( 'Error, len(self.project.explanations_for_inconsistent_ontology) >0 and len(self.project.explanations_for_unsatisfiable_classes) >0:' ) sys.exit(0) #choose the explanation if len(self.project.explanations_for_inconsistent_ontology) > 0: explanations_for_widget = self.project.explanations_for_inconsistent_ontology else: if 'ConceptNode' in self.project.uc_as_input_for_explanation_explorer: unsatisfiable_entities = self.project.unsatisfiable_classes explanations_unsatisfiable_entity = self.project.explanations_for_unsatisfiable_classes elif 'AttributeNode' in self.project.uc_as_input_for_explanation_explorer: unsatisfiable_entities = self.project.unsatisfiable_attributes explanations_unsatisfiable_entity = self.project.explanations_for_unsatisfiable_attributes elif 'RoleNode' in self.project.uc_as_input_for_explanation_explorer: unsatisfiable_entities = self.project.unsatisfiable_roles explanations_unsatisfiable_entity = self.project.explanations_for_unsatisfiable_roles #print('self.project.uc_as_input_for_explanation_explorer',self.project.uc_as_input_for_explanation_explorer) #print('self.project.uc_as_input_for_explanation_explorer',self.project.uc_as_input_for_explanation_explorer) inp_node = None for n in self.project.nodes(): if str(n) == self.project.uc_as_input_for_explanation_explorer: inp_node = n OWL_term_uc_as_input_for_explanation_explorer = self.project.getOWLtermfornode( inp_node) index_uc = unsatisfiable_entities.index( OWL_term_uc_as_input_for_explanation_explorer) explanations_for_widget = explanations_unsatisfiable_entity[ index_uc] for explanation_count, e in enumerate(explanations_for_widget): self.sgnFakeExplanationAdded.emit(str(explanation_count + 1)) for explanation_count, e in enumerate(explanations_for_widget): axioms_for_iteration = [] if self.project.inconsistent_ontology is True: axioms_temp = e.getAxioms() axioms_temp_itr = axioms_temp.iterator() while (axioms_temp_itr.hasNext()): axiom_temp = axioms_temp_itr.next() axioms_for_iteration.append(axiom_temp) else: e_itr = e.iterator() while (e_itr.hasNext()): axiom_temp = e_itr.next() axioms_for_iteration.append(axiom_temp) for axiom_count, axiom_e in enumerate(axioms_for_iteration): q_exp_items = widget.model.findItems( 'Explanation - ' + str(explanation_count + 1), flags=QtCore.Qt.MatchExactly, column=0) if len(q_exp_items) != 1: LOGGER.error( 'multiple or 0 QStandardItems found for q_exp_item') sys.exit(0) cast(autoclass('org.semanticweb.owlapi.model.OWLAxiom'), axiom_e) self.sgnFakeAxiomAdded.emit(q_exp_items[0], axiom_e.toString()) q_axiom_item = q_exp_items[0].child(axiom_count, 0) nodes_and_edges = self.project.axioms_to_nodes_edges_mapping[ q_axiom_item.text()] nodes_to_add_in_widget = set() edges_to_add_in_widget = set() for ne in nodes_and_edges: if 'eddy.core.items.nodes' in str(type(ne)): nodes_to_add_in_widget.add(ne) elif 'eddy.core.items.edges' in str(type(ne)): edges_to_add_in_widget.add(ne) else: pass for node in nodes_to_add_in_widget: self.sgnFakeItemAdded.emit(node.diagram, node, q_axiom_item) for edge in edges_to_add_in_widget: self.sgnFakeItemAdded.emit(edge.diagram, edge, q_axiom_item) disconnect(self.sgnFakeExplanationAdded, widget.doAddExplanation) disconnect(self.sgnFakeAxiomAdded, widget.doAddAxiom) disconnect(self.sgnFakeItemAdded, widget.doAddNodeOREdge)
def closeEvent(self, QCloseEvent): disconnect(self.table.cellPressed, self.cell_pressed) disconnect(self.table.cellChanged, self.cell_changed) disconnect(self.project.sgnIRIPrefixNodeDictionaryUpdated, self.UpdateTableForIRI) disconnect(self.project.sgnIRIPrefixesEntryModified, self.entry_MODIFY_ok) disconnect(self.project.sgnIRIPrefixEntryAdded, self.entry_ADD_ok) disconnect(self.project.sgnIRIPrefixEntryRemoved, self.entry_REMOVE_OK) disconnect(self.project.sgnIRIPrefixesEntryIgnored, self.entry_NOT_OK) self.close()
def dispose(self): """ Executed whenever the plugin is going to be destroyed. """ # DISCONNECT FROM ALL THE DIAGRAMS for diagram in self.project.diagrams(): self.debug('Disconnecting from diagrams: %s', diagram.name) disconnect(diagram.sgnItemInsertionCompleted, self.onDiagramItemInsertionCompleted) disconnect(diagram.sgnModeChanged, self.onDiagramModeChanged) # DISCONNECT FROM CURRENT PROJECT self.debug('Disconnecting from project: %s', self.project.name) disconnect(self.project.sgnDiagramAdded, self.onDiagramAdded) disconnect(self.project.sgnDiagramRemoved, self.onDiagramRemoved) disconnect(self.project.sgnUpdated, self.doActivatePalette) # DISCONNECT FROM ACTIVE SESSION self.debug('Disconnecting from active session') disconnect(self.session.sgnReady, self.onSessionReady) # REMOVE DOCKING AREA WIDGET MENU ENTRY self.debug('Removing docking area widget toggle from "view" menu') menu = self.session.menu('view') menu.removeAction(self.widget('palette_dock').toggleViewAction()) # UNINSTALL THE PALETTE DOCK WIDGET self.debug('Uninstalling docking area widget') self.session.removeDockWidget(self.widget('palette_dock'))
def doUpdateExplanations(self): """ Executed when the ontology is inconsistent or there are unsatisfiable classes to update the explanations. """ # CONNECT TO PROJECT SPECIFIC SIGNALS widget = self.widget('explanation_explorer') widget.doClear() # FILL IN EXPLANATION EXPLORER WITH DATA connect(self.sgnFakeExplanationAdded, widget.doAddExplanation) connect(self.sgnFakeAxiomAdded, widget.doAddAxiom) connect(self.sgnFakeItemAdded, widget.doAddNodeOREdge) self.vm = getJavaVM() if not self.vm.isRunning(): self.vm.initialize() self.vm.attachThreadToJVM() # Choose the explanation if len(self.project.explanations_for_inconsistent_ontology) > 0: explanations_for_widget = self.project.explanations_for_inconsistent_ontology else: if 'ConceptNode' in self.project.uc_as_input_for_explanation_explorer: unsatisfiable_entities = self.project.unsatisfiable_classes explanations_unsatisfiable_entity = self.project.explanations_for_unsatisfiable_classes elif 'AttributeNode' in self.project.uc_as_input_for_explanation_explorer: unsatisfiable_entities = self.project.unsatisfiable_attributes explanations_unsatisfiable_entity = self.project.explanations_for_unsatisfiable_attributes elif 'RoleNode' in self.project.uc_as_input_for_explanation_explorer: unsatisfiable_entities = self.project.unsatisfiable_roles explanations_unsatisfiable_entity = self.project.explanations_for_unsatisfiable_roles inp_node = None for n in self.project.nodes(): if str(n) == self.project.uc_as_input_for_explanation_explorer: inp_node = n break OWL_term_uc_as_input_for_explanation_explorer = self.project.getOWLtermfornode( inp_node) index_uc = unsatisfiable_entities.index( OWL_term_uc_as_input_for_explanation_explorer) explanations_for_widget = explanations_unsatisfiable_entity[ index_uc] for explanation_count, e in enumerate(explanations_for_widget): self.sgnFakeExplanationAdded.emit(str(explanation_count + 1)) for explanation_count, e in enumerate(explanations_for_widget): axioms_for_iteration = [] if self.project.inconsistent_ontology: axioms_temp = e.getAxioms() axioms_temp_itr = axioms_temp.iterator() while axioms_temp_itr.hasNext(): axiom_temp = axioms_temp_itr.next() axioms_for_iteration.append(axiom_temp) else: e_itr = e.iterator() while e_itr.hasNext(): axiom_temp = e_itr.next() axioms_for_iteration.append(axiom_temp) for axiom_count, axiom_e in enumerate(axioms_for_iteration): q_exp_items = widget.model.findItems( 'Explanation - ' + str(explanation_count + 1), flags=QtCore.Qt.MatchExactly, column=0) if len(q_exp_items) != 1: LOGGER.error( 'multiple or 0 QStandardItems found for q_exp_item') self.sgnFakeAxiomAdded.emit(q_exp_items[0], axiom_e.toString()) q_axiom_item = q_exp_items[0].child(axiom_count, 0) nodes_and_edges = self.project.axioms_to_nodes_edges_mapping[ q_axiom_item.text()] nodes_to_add_in_widget = set() edges_to_add_in_widget = set() for ne in nodes_and_edges: if 'eddy.core.items.nodes' in str(type(ne)): nodes_to_add_in_widget.add(ne) elif 'eddy.core.items.edges' in str(type(ne)): edges_to_add_in_widget.add(ne) for node in nodes_to_add_in_widget: self.sgnFakeItemAdded.emit(node.diagram, node, q_axiom_item) for edge in edges_to_add_in_widget: self.sgnFakeItemAdded.emit(edge.diagram, edge, q_axiom_item) disconnect(self.sgnFakeExplanationAdded, widget.doAddExplanation) disconnect(self.sgnFakeAxiomAdded, widget.doAddAxiom) disconnect(self.sgnFakeItemAdded, widget.doAddNodeOREdge) # SHOW THE PLUGIN DOCK WIDGET if not self.widget('explanation_explorer_dock').isVisible(): self.widget( 'explanation_explorer_dock').toggleViewAction().trigger() self.widget('explanation_explorer_dock').raise_()
def dispose(self): """ Executed whenever the plugin is going to be destroyed. """ # DISCONNECT FROM CURRENT PROJECT widget = self.widget('explanation_explorer') self.debug('Disconnecting from project: %s', self.project.name) disconnect(self.project.sgnItemAdded, widget.doAddNode) disconnect(self.project.sgnItemRemoved, widget.doRemoveNode) # DISCONNECT FROM ACTIVE SESSION self.debug('Disconnecting from active session') disconnect(self.session.sgnReady, self.onSessionReady) disconnect(self.session.sgnConsistencyCheckStarted, self.onConsistencyCheckStarted) disconnect(self.session.sgnConsistencyCheckReset, self.onConsistencyCheckReset) disconnect(self.session.sgnPerfectOntology, self.onPerfectOntology) disconnect(self.session.sgnInconsistentOntology, self.onInconsistentOntology) disconnect(self.session.sgnUnsatisfiableEntities, self.onUnsatisfiableEntities) # REMOVE DOCKING AREA WIDGET MENU ENTRY self.debug('Removing docking area widget toggle from "view" menu') menu = self.session.menu('view') menu.removeAction( self.widget('explanation_explorer_dock').toggleViewAction()) # UNINSTALL THE PALETTE DOCK WIDGET self.debug('Uninstalling docking area widget') self.session.removeDockWidget(self.widget('explanation_explorer_dock'))
def disconnectIRIMetaSignals(self): disconnect(self.iri.sgnFunctionalModified, self.onFunctionalModified)
def FillTableWithIRIPrefixNodesDictionaryKeysAndValues(self): #if (iri_to_update is None) and (nodes_to_update is None): #print('>>> FillTableWithIRIPrefixNodesDictionaryKeysAndValues') # first delete all entries from the dictionary id present # add standard IRIs # add key value pairs from dict for r in range(0, self.table.rowCount() + 1): iri_item_to_el = self.table.item(r, 0) del iri_item_to_el prefix_item_to_del = self.table.item(r, 1) del prefix_item_to_del cw = self.table.cellWidget(r, 2) if cw is not None: disconnect(cw.toggled, self.set_project_IRI) self.table.removeCellWidget(r, 2) cw.destroy() self.table.clear() self.table.setRowCount(1) self.table.setColumnCount(3) header_iri = QtWidgets.QTableWidgetItem() header_iri.setText('IRI') header_iri.setFont(Font('Roboto', 15, bold=True)) header_iri.setTextAlignment(QtCore.Qt.AlignCenter) #header_iri.setBackground(QtGui.QBrush(QtGui.QColor(90, 80, 80, 200))) #header_iri.setForeground(QtGui.QBrush(QtGui.QColor(255, 255, 255, 255))) header_iri.setBackground(QtGui.QBrush(QtGui.QColor(255, 255, 255, 255))) header_iri.setForeground(QtGui.QBrush(QtGui.QColor(90, 80, 80, 200))) header_iri.setFlags(QtCore.Qt.NoItemFlags) header_prefix = QtWidgets.QTableWidgetItem() header_prefix.setText('PREFIX') header_prefix.setFont(Font('Roboto', 15, bold=True)) header_prefix.setTextAlignment(QtCore.Qt.AlignCenter) #header_prefix.setBackground(QtGui.QBrush(QtGui.QColor(90, 80, 80, 200))) #header_prefix.setForeground(QtGui.QBrush(QtGui.QColor(255, 255, 255, 255))) header_prefix.setBackground( QtGui.QBrush(QtGui.QColor(255, 255, 255, 255))) header_prefix.setForeground(QtGui.QBrush(QtGui.QColor(90, 80, 80, 200))) header_prefix.setFlags(QtCore.Qt.NoItemFlags) header_project_prefix = QtWidgets.QTableWidgetItem() header_project_prefix.setText('DEFAULT') header_project_prefix.setFont(Font('Roboto', 15, bold=True)) header_project_prefix.setTextAlignment(QtCore.Qt.AlignCenter) #header_project_prefix.setBackground(QtGui.QBrush(QtGui.QColor(90, 80, 80, 200))) #header_project_prefix.setForeground(QtGui.QBrush(QtGui.QColor(255, 255, 255, 255))) header_project_prefix.setBackground( QtGui.QBrush(QtGui.QColor(255, 255, 255, 255))) header_project_prefix.setForeground( QtGui.QBrush(QtGui.QColor(90, 80, 80, 200))) header_project_prefix.setFlags(QtCore.Qt.NoItemFlags) self.table.setItem(self.table.rowCount() - 1, 0, header_iri) self.table.setItem(self.table.rowCount() - 1, 1, header_prefix) self.table.setItem(self.table.rowCount() - 1, 2, header_project_prefix) self.table.setRowCount(self.table.rowCount() + 1) for iri in self.project.IRI_prefixes_nodes_dict.keys(): if iri in OWLStandardIRIPrefixPairsDict.std_IRI_prefix_dict.keys(): standard_prefixes = self.project.IRI_prefixes_nodes_dict[iri][ 0] standard_prefix = standard_prefixes[0] self.append_row_and_column_to_table(iri, standard_prefix, False, None, 0) #QtGui.QBrush(QtGui.QColor(50, 50, 205, 50))) """ iri = self.project.iri prefixes = self.project.IRI_prefixes_nodes_dict[self.project.iri][0] if len(prefixes) > 0: for p in prefixes: #self.append_row_and_column_to_table(iri, p, True, QtGui.QBrush(QtGui.QColor(205, 50, 50, 50))) self.append_row_and_column_to_table(iri, p, True, None, 2) else: #self.append_row_and_column_to_table(iri, '', True, QtGui.QBrush(QtGui.QColor(205, 50, 50, 50))) self.append_row_and_column_to_table(iri, '', True, None, 2) """ for iri in sorted(self.project.IRI_prefixes_nodes_dict.keys()): if iri in OWLStandardIRIPrefixPairsDict.std_IRI_prefix_dict.keys(): continue prefixes = self.project.IRI_prefixes_nodes_dict[iri][0] if len(prefixes) > 0: for p in prefixes: if iri == self.project.iri: self.append_row_and_column_to_table( iri, p, True, None, 2) else: self.append_row_and_column_to_table( iri, p, True, None, 1) else: if 'display_in_widget' in self.project.IRI_prefixes_nodes_dict[ iri][2]: if iri == self.project.iri: self.append_row_and_column_to_table( iri, '', True, None, 2) else: self.append_row_and_column_to_table( iri, '', True, None, 1) self.append_row_and_column_to_table('', '', True, None, 0) self.table.setRowCount(self.table.rowCount() - 1) self.redraw()