# Path: src/pySUMOQt/Widget/Widget.py
# class RWidget(PySUMOWidget):
# 
#     """ Class for Widgets which only has read-access to the Ontologies. This
#     class should not be used directly, but extended.
#     """
# 
#     def __init__(self, mainwindow):
#         """ Initializes the RWidget. """
#         super(RWidget, self).__init__(mainwindow)


import logging
from PySide.QtCore import Slot, QTimer
from PySide.QtGui import QApplication, QMainWindow
from multiprocessing import Process, Pipe
from atexit import register, unregister
from pySUMOQt.Designer.DocumentationWidget import Ui_Form
from .Widget import RWidget
        """ Initializes the DocumentationWidget. """
        super(DocumentationWidget, self).__init__(mainwindow)
        self.setupUi(mainwindow)
        self.lineEdit.returnPressed.connect(self.search)
        self.log = logging.getLogger('.' + __name__)
        if len(DocumentationWidget._WN_TROOL) == 0:
            DocumentationWidget._WN_TROOL.append(1)
            (DocumentationWidget._WN_RECV, DocumentationWidget._WN_SEND) = Pipe(False)
            DocumentationWidget._WN_PROCESS = Process(target=DocumentationWidget._initialize, args=(DocumentationWidget._WN_SEND,))
            DocumentationWidget._WN_PROCESS.start()
            register(DocumentationWidget._WN_PROCESS.terminate)
            register(DocumentationWidget._WN_SEND.close)
            register(DocumentationWidget._WN_RECV.close)

    @classmethod
    def _initialize(cls, pipe):
        cls.IA.init_wordnet()
        pipe.send(cls.IA.wordnet)

    @Slot()
    def search(self):
        """ Uses the IndexAbstractor to search for all occurrences of
        string in the Ontology and displays them.  """
        if len(DocumentationWidget._WN_TROOL) == 1:
            if not DocumentationWidget._WN_RECV.poll():
                self.log.info('Searching')
                self._TIMER.timeout.connect(self.search)
                self._TIMER.start(3000)
                return
            DocumentationWidget._WN_TROOL.append(2)

# Path: src/pySUMOQt/Widget/Widget.py
# class RWidget(PySUMOWidget):
# 
#     """ Class for Widgets which only has read-access to the Ontologies. This
#     class should not be used directly, but extended.
#     """
# 
#     def __init__(self, mainwindow):
#         """ Initializes the RWidget. """
#         super(RWidget, self).__init__(mainwindow)


# Path: src/pySUMOQt/Widget/DocumentationWidget.py
import logging
from PySide.QtCore import Slot, QTimer
from PySide.QtGui import QApplication, QMainWindow
from multiprocessing import Process, Pipe
from atexit import register, unregister
from pySUMOQt.Designer.DocumentationWidget import Ui_Form
from .Widget import RWidget

        """ Initializes the DocumentationWidget. """
        super(DocumentationWidget, self).__init__(mainwindow)
        self.setupUi(mainwindow)
        self.lineEdit.returnPressed.connect(self.search)
        self.log = logging.getLogger('.' + __name__)
        if len(DocumentationWidget._WN_TROOL) == 0:
            DocumentationWidget._WN_TROOL.append(1)
            (DocumentationWidget._WN_RECV, DocumentationWidget._WN_SEND) = Pipe(False)
            DocumentationWidget._WN_PROCESS = Process(target=DocumentationWidget._initialize, args=(DocumentationWidget._WN_SEND,))
            DocumentationWidget._WN_PROCESS.start()
            register(DocumentationWidget._WN_PROCESS.terminate)
            register(DocumentationWidget._WN_SEND.close)
            register(DocumentationWidget._WN_RECV.close)

    @classmethod
    def _initialize(cls, pipe):
        cls.IA.init_wordnet()
        pipe.send(cls.IA.wordnet)

    @Slot()
    def search(self):
        """ Uses the IndexAbstractor to search for all occurrences of
        string in the Ontology and displays them.  """
        if len(DocumentationWidget._WN_TROOL) == 1:
            if not DocumentationWidget._WN_RECV.poll():
                self.log.info('Searching')
                self._TIMER.timeout.connect(self.search)
                self._TIMER.start(3000)
                return
            DocumentationWidget._WN_TROOL.append(2)

            RWidget.IA.wordnet = DocumentationWidget._WN_RECV.recv()