<commit_before>'''
Created on Feb 21, 2017

@author: lubo
'''
from tkviews.tkimport import *  # @UnusedWildImport


from tkviews.open_ui import OpenUi
from tkviews.pinmat_ui import PinmatUi
from tkviews.sectors_ui import SectorsUi

from tkviews.base_window import BaseHeatmapWindow

from models.sector_model import SectorsDataModel
from tkviews.sectors_window import SectorsWindow
from models.pinmat_model import PinmatModel
from controllers.controller import PinmatController, SectorsController
from models.subject import DataSubject


class MainWindow(BaseHeatmapWindow):

    def __init__(self, master, controller, subject):
        super(MainWindow, self).__init__(master, controller, subject)
        self.controller.register_on_model_callback(self.on_model_callback)

    def build_ui(self):
        self.build_base_ui()

        pinmat = PinmatUi(
            self.main.button_ext, self.controller, self.subject)
        pinmat.build_ui()
        pinmat.register_on_pinmat(self.build_pinmat)

        sectors = SectorsUi(
            self.main.button_ext, self.controller, self.subject)
        sectors.build_ui()
        sectors.register_on_sectors_reorder(self.build_sectors_reorder)

        open_buttons = OpenUi(self.main.button_ext, self.subject)
        open_buttons.build_ui()

    def on_model_callback(self, model):
        self.model = model
        self.draw_canvas()

    def build_pinmat(self, pinmat_button):
        pinmat_button.disable_ui()

        root = tk.Toplevel()
        model = PinmatModel(self.model)
        # model.make()

        controller = PinmatController(model)
        pinmat_window = BaseHeatmapWindow(root, controller)
        pinmat_window.build_ui()

        def on_close():
            pinmat_button.enable_ui()
        pinmat_window.register_on_closing_callback(on_close)

        pinmat_window.draw_canvas()
        root.mainloop()

    def build_sectors_reorder(self, sectors_button):
        sectors_button.disable_ui()

        root = tk.Toplevel()
        sectors_model = SectorsDataModel(self.model)
        sectors_model.make()

        controller = SectorsController(sectors_model)
        subject = DataSubject()
        sectors_window = SectorsWindow(root, controller, subject)<commit_msg>implement observer and command pattern <commit_after>'''
Created on Feb 21, 2017

@author: lubo
'''
from tkviews.tkimport import *  # @UnusedWildImport


from tkviews.open_ui import OpenUi
from tkviews.pinmat_ui import PinmatUi
from tkviews.sectors_ui import SectorsUi

from tkviews.base_window import BaseHeatmapWindow

from models.sector_model import SectorsDataModel
from tkviews.sectors_window import SectorsWindow
from models.pinmat_model import PinmatModel
from controllers.controller import PinmatController, SectorsController
from models.subject import DataSubject


class MainWindow(BaseHeatmapWindow):

    def __init__(self, master, controller, subject):
        super(MainWindow, self).__init__(master, controller, subject)
        self.controller.register_on_model_callback(self.on_model_callback)

    def build_ui(self):
        self.build_base_ui()

        pinmat = PinmatUi(
            self.main.button_ext, self.controller, self.subject)
        pinmat.build_ui()
        pinmat.register_on_pinmat(self.build_pinmat)

        sectors = SectorsUi(
            self.main.button_ext, self.controller, self.subject)
        sectors.build_ui()
        sectors.register_on_sectors_reorder(self.build_sectors_reorder)

        open_buttons = OpenUi(self.main.button_ext, self.subject)
        open_buttons.build_ui()

    def on_model_callback(self, model):
        self.model = model
        self.draw_canvas()

    def build_pinmat(self, pinmat_button):
        pinmat_button.disable_ui()

        root = tk.Toplevel()
        model = PinmatModel(self.model)
        # model.make()

        controller = PinmatController(model)
        subject = DataSubject()
        pinmat_window = BaseHeatmapWindow(root, controller, subject)
        pinmat_window.build_ui()

        subject.set_model(model)

        def on_close():
            pinmat_button.enable_ui()
        pinmat_window.register_on_closing_callback(on_close)

        pinmat_window.draw_canvas()
        root.mainloop()

    def build_sectors_reorder(self, sectors_button):
        sectors_button.disable_ui()

        root = tk.Toplevel()
        sectors_model = SectorsDataModel(self.model)
        sectors_model.make()

        controller = SectorsController(sectors_model)
        subject = DataSubject()
        sectors_window = SectorsWindow(root, controller, subject)
{'fraction_non_alphanumeric': 0.07893020221787345, 'fraction_numerical': 0.002609262883235486, 'mean_word_length': 3.3355325164938736, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1983593', 'n_tokens_mistral': 1417, 'n_tokens_neox': 1355, 'n_words': 260}