File: db_copy_main.py

package info (click to toggle)
mysql-workbench 6.3.8%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 113,932 kB
  • ctags: 87,814
  • sloc: ansic: 955,521; cpp: 427,465; python: 59,728; yacc: 59,129; xml: 54,204; sql: 7,091; objc: 965; makefile: 638; sh: 613; java: 237; perl: 30; ruby: 6; php: 1
file content (153 lines) | stat: -rw-r--r-- 5,039 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; version 2 of the
# License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301  USA

import locale
import platform
import mforms

import migration

import db_copy_overview
import db_copy_source_target
import db_copy_schema_selection
import db_copy_progress
import db_copy_report


#===============================================================================
#
#===============================================================================
class DBCopy(mforms.AppView):
    def __init__(self):
        mforms.AppView.__init__(self, False, 'db_copy', True)

        self.background = None
        self.content = mforms.newBox(False)

        if platform.system() == 'Windows':
            self.set_back_color(mforms.App.get().get_system_color(mforms.SystemColorContainer).to_html())
            content_panel = mforms.newPanel(mforms.FilledPanel)
            #self.content.set_back_image("migration_background.png", mforms.TopRight)
            content_panel.set_back_color("#FFFFFF")
        else:
            content_panel = mforms.newPanel(mforms.StyledHeaderPanel)
            content_panel.set_back_image("migration_background.png", mforms.TopRight)
          
        content_panel.set_padding(8)
        self.header = mforms.newLabel("")
        self.header.set_style(mforms.WizardHeadingStyle)
        self.content.add(self.header, False)

        # On Windows doesn't use TabView as it is not transparent
        if platform.system() != 'Windows':
            self.tabview = mforms.newTabView(mforms.TabViewTabless)
            self.content.add(self.tabview, True, True)

        content_panel.add(self.content)
        self.add(content_panel, True, True)

        self._ui_created = False
        
        self._page_list = []
        self._page_trail = []
        self._current_page = 0

        # Load current user numeric locale:
        locale.setlocale(locale.LC_NUMERIC, '')

        self.plan = migration.MigrationPlan()
        self.create_ui()


    def advanced(self):
        self._page_trail[-1].advanced_clicked()


    def reset(self):
        self._current_page = 0
        self._page_trail = [self._page_list[0]]
        self.switch_page(advancing=True)


    def create_ui(self):
        if self._ui_created:
            return

        self._ui_created = True

        self._overview_page = db_copy_overview.MainView(self)
        self._source_target_page = db_copy_source_target.SourceTargetMainView(self)
        self._schema_selection_page = db_copy_schema_selection.SchemaMainView(self)
        self._progress_page = db_copy_progress.ProgressMainView(self)
        self._report_page = db_copy_report.ReportMainView(self)

        self._page_list = [self._overview_page,
                           self._source_target_page,
                           self._schema_selection_page,
                           self._progress_page,
                           self._report_page
                          ]

        if platform.system() == 'Windows':
            for p in self._page_list:
                self.content.add(p, True, True)
                p.show(False)
        else:
            for p in self._page_list:
                self.tabview.add_page(p, "")

        self._page_trail = [self._page_list[self._current_page]]
        self.switch_page(advancing=True)


    def switch_page(self, advancing):
        curpage = self._page_trail[-1]

        if platform.system() == 'Windows':
            for p in self._page_list:
                if p == curpage:
                    p.page_activated(advancing)
                p.show(p == curpage)
        else:
            i = self._page_list.index(curpage)
            self.tabview.set_active_tab(i)
            curpage.page_activated(advancing)


    def go_next_page(self):
        self._current_page += 1
        self._page_trail.append(self._page_list[self._current_page])
        self.switch_page(advancing=True)


    def go_previous_page(self):
        if len(self._page_trail) > 1:
            self._page_trail.pop()
            self._current_page = self._page_list.index(self._page_trail[-1])
            self.switch_page(advancing=False)


    def close(self):
        # Restore default locale:
        locale.setlocale(locale.LC_NUMERIC, 'C')
        super(DBCopy, self).close()
        
    
    def cleanup(self):
        if self.plan:
            self.plan.close()
        self.plan = None