annotate src/browser/sat_browser/xmlui.py @ 500:67a4e8383b70

browser side (XMLUI): XMLUI update to follow core changes: - Dialogs are now managed - FileDialog raise a NotImplementedError, it's not yet possible in Libervia - XMLUIPanel.show is implemented - following core changes, we now create an XMLUI with xmlui.create(...) - WidgetFactory now inherit from GenericFactory - workaround for __getattr__ bug in pyjamas, now createXXX are automaticaly created with inspection
author Goffi <goffi@goffi.org>
date Wed, 13 Aug 2014 14:09:09 +0200
parents 1ce6133993e4
children f030491cff75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
3
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 337
diff changeset
4 # Libervia: a Salut à Toi frontend
340
ce5b33f499c5 dates update
Goffi <goffi@goffi.org>
parents: 339
diff changeset
5 # Copyright (C) 2011, 2012, 2013, 2014 Jérôme Poisson <goffi@goffi.org>
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
6
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 337
diff changeset
7 # This program is free software: you can redistribute it and/or modify
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 337
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 337
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 337
diff changeset
10 # (at your option) any later version.
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
11
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 337
diff changeset
12 # This program is distributed in the hope that it will be useful,
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 337
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 337
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 337
diff changeset
15 # GNU Affero General Public License for more details.
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
16
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 337
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 337
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
19
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 430
diff changeset
20 from sat.core.log import getLogger
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 430
diff changeset
21 log = getLogger(__name__)
449
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 439
diff changeset
22 from sat_frontends.tools import xmlui
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
23 from sat_browser.constants import Const as C
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
24 from sat_browser import dialog
449
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 439
diff changeset
25
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from pyjamas.ui.VerticalPanel import VerticalPanel
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
27 from pyjamas.ui.HorizontalPanel import HorizontalPanel
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
28 from pyjamas.ui.TabPanel import TabPanel
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
29 from pyjamas.ui.Grid import Grid
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
30 from pyjamas.ui.Label import Label
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
31 from pyjamas.ui.TextBox import TextBox
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
32 from pyjamas.ui.PasswordTextBox import PasswordTextBox
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
33 from pyjamas.ui.TextArea import TextArea
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
34 from pyjamas.ui.CheckBox import CheckBox
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
35 from pyjamas.ui.ListBox import ListBox
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
36 from pyjamas.ui.Button import Button
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
37 from pyjamas.ui.HTML import HTML
449
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 439
diff changeset
38
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 451
diff changeset
39 import nativedom
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
40
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
41
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
42 class EmptyWidget(xmlui.EmptyWidget, Label):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
43
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
44 def __init__(self, _xmlui_parent):
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
45 Label.__init__(self, '')
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
46
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
47
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
48 class TextWidget(xmlui.TextWidget, Label):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
49
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
50 def __init__(self, _xmlui_parent, value):
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
51 Label.__init__(self, value)
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
52
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
53
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
54 class LabelWidget(xmlui.LabelWidget, TextWidget):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
55
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
56 def __init__(self, _xmlui_parent, value):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
57 TextWidget.__init__(self, _xmlui_parent, value + ": ")
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
58
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
59
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
60 class JidWidget(xmlui.JidWidget, TextWidget):
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
61
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
62 def __init__(self, _xmlui_parent, value):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
63 TextWidget.__init__(self, _xmlui_parent, value)
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
64
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
65
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
66 class DividerWidget(xmlui.DividerWidget, HTML):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
67
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
68 def __init__(self, _xmlui_parent, style='line'):
428
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
69 """Add a divider
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
70
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
71 @param _xmlui_parent
428
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
72 @param style (string): one of:
489
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
73 - line: a simple line
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
74 - dot: a line of dots
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
75 - dash: a line of dashes
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
76 - plain: a full thick line
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
77 - blank: a blank line/space
428
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
78 """
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
79 HTML.__init__(self, "<hr/>")
0c4547587637 browser_side (xmlui): implement the divider styles
souliane <souliane@mailoo.org>
parents: 392
diff changeset
80 self.addStyleName(style)
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
81
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
82
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
83 class StringWidget(xmlui.StringWidget, TextBox):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
84
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
85 def __init__(self, _xmlui_parent, value, read_only=False):
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
86 TextBox.__init__(self)
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
87 self.setText(value)
489
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
88 self.setReadonly(read_only)
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
89
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
90 def _xmluiSetValue(self, value):
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
91 self.setText(value)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
92
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
93 def _xmluiGetValue(self):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
94 return self.getText()
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
95
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
96 def _xmluiOnChange(self, callback):
378
3dd0b5334aef browser_side: fix typos
souliane <souliane@mailoo.org>
parents: 376
diff changeset
97 self.addChangeListener(callback)
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
98
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
99
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
100 class PasswordWidget(xmlui.PasswordWidget, PasswordTextBox):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
101
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
102 def __init__(self, _xmlui_parent, value, read_only=False):
390
76583fab7ea0 browser_side: fix XMLUI password box initialisation
souliane <souliane@mailoo.org>
parents: 378
diff changeset
103 PasswordTextBox.__init__(self)
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
104 self.setText(value)
489
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
105 self.setReadonly(read_only)
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
106
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
107 def _xmluiSetValue(self, value):
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
108 self.setText(value)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
109
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
110 def _xmluiGetValue(self):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
111 return self.getText()
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
112
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
113 def _xmluiOnChange(self, callback):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
114 self.addChangeListener(callback)
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
115
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
116
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
117 class TextBoxWidget(xmlui.TextBoxWidget, TextArea):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
118
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
119 def __init__(self, _xmlui_parent, value, read_only=False):
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
120 TextArea.__init__(self)
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
121 self.setText(value)
489
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
122 self.setReadonly(read_only)
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
123
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
124 def _xmluiSetValue(self, value):
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
125 self.setText(value)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
126
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
127 def _xmluiGetValue(self):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
128 return self.getText()
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
129
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
130 def _xmluiOnChange(self, callback):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
131 self.addChangeListener(callback)
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
132
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
133
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
134 class BoolWidget(xmlui.BoolWidget, CheckBox):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
135
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
136 def __init__(self, _xmlui_parent, state, read_only=False):
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
137 CheckBox.__init__(self)
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
138 self.setChecked(state)
489
1ce6133993e4 browser side (XMLUI): implementation of read_only attribute
Goffi <goffi@goffi.org>
parents: 467
diff changeset
139 self.setReadonly(read_only)
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
140
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
141 def _xmluiSetValue(self, value):
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
142 self.setChecked(value == "true")
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
143
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
144 def _xmluiGetValue(self):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
145 return "true" if self.isChecked() else "false"
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
146
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
147 def _xmluiOnChange(self, callback):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
148 self.addClickListener(callback)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
149
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
150
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
151 class ButtonWidget(xmlui.ButtonWidget, Button):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
152
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
153 def __init__(self, _xmlui_parent, value, click_callback):
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
154 Button.__init__(self, value, click_callback)
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
155
378
3dd0b5334aef browser_side: fix typos
souliane <souliane@mailoo.org>
parents: 376
diff changeset
156 def _xmluiOnClick(self, callback):
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
157 self.addClickListener(callback)
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
158
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
159
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
160 class ListWidget(xmlui.ListWidget, ListBox):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
161
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
162 def __init__(self, _xmlui_parent, options, selected, flags):
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
163 ListBox.__init__(self)
430
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
164 multi_selection = 'single' not in flags
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
165 self.setMultipleSelect(multi_selection)
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
166 if multi_selection:
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
167 self.setVisibleItemCount(5)
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
168 for option in options:
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
169 self.addItem(option[1])
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
170 self._xmlui_attr_map = {label: value for value, label in options}
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
171 self._xmluiSelectValues(selected)
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
172
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
173 def _xmluiSelectValue(self, value):
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
174 """Select a value checking its item"""
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
175 try:
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
176 label = [label for label, _value in self._xmlui_attr_map.items() if _value == value][0]
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
177 except IndexError:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 430
diff changeset
178 log.warning("Can't find value [%s] to select" % value)
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
179 return
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
180 self.selectItem(label)
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
181
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
182 def _xmluiSelectValues(self, values):
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
183 """Select multiple values, ignore the items"""
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
184 self.setValueSelection(values)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
185
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
186 def _xmluiGetSelectedValues(self):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
187 ret = []
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
188 for label in self.getSelectedItemText():
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
189 ret.append(self._xmlui_attr_map[label])
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
190 return ret
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
191
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
192 def _xmluiOnChange(self, callback):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
193 self.addChangeListener(callback)
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
194
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
195 def _xmluiAddValues(self, values, select=True):
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
196 selected = self._xmluiGetSelectedValues()
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
197 for value in values:
430
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
198 if value not in self._xmlui_attr_map.values():
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
199 self.addItem(value)
a927a98b398d browser_side (xmlui): fix multi-selection
souliane <souliane@mailoo.org>
parents: 429
diff changeset
200 self._xmlui_attr_map[value] = value
429
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
201 if value not in selected:
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
202 selected.append(value)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
203 self._xmluiSelectValues(selected)
9283f9e5e5dd browser_side (xmlui): added setter methods + manage multi-selection for list widgets
souliane <souliane@mailoo.org>
parents: 428
diff changeset
204
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
205
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
206 class LiberviaContainer(object):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
207
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
208 def _xmluiAppend(self, widget):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
209 self.append(widget)
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
210
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
211
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
212 class AdvancedListContainer(xmlui.AdvancedListContainer, Grid):
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
213
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
214 def __init__(self, _xmlui_parent, columns, selectable='no'):
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
215 Grid.__init__(self, 0, columns)
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
216 self.columns = columns
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
217 self.row = -1
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
218 self.col = 0
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
219 self._xmlui_rows_idx = []
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
220 self._xmlui_selectable = selectable != 'no'
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
221 self._xmlui_selected_row = None
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
222 self.addTableListener(self)
376
ab923b870fb0 browser side: XMLUI AdvancedListContainer: rows are highlighted when there are selectable
Goffi <goffi@goffi.org>
parents: 369
diff changeset
223 if self._xmlui_selectable:
ab923b870fb0 browser side: XMLUI AdvancedListContainer: rows are highlighted when there are selectable
Goffi <goffi@goffi.org>
parents: 369
diff changeset
224 self.addStyleName('AdvancedListSelectable')
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
225
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
226 def onCellClicked(self, grid, row, col):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
227 if not self._xmlui_selectable:
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
228 return
376
ab923b870fb0 browser side: XMLUI AdvancedListContainer: rows are highlighted when there are selectable
Goffi <goffi@goffi.org>
parents: 369
diff changeset
229 self._xmlui_selected_row = row
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
230 try:
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
231 self._xmlui_select_cb(self)
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
232 except AttributeError:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 430
diff changeset
233 log.warning("no select callback set")
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
234
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
235 def _xmluiAppend(self, widget):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
236 self.setWidget(self.row, self.col, widget)
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
237 self.col += 1
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
238
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
239 def _xmluiAddRow(self, idx):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
240 self.row += 1
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
241 self.col = 0
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
242 self._xmlui_rows_idx.insert(self.row, idx)
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
243 self.resizeRows(self.row + 1)
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
244
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
245 def _xmluiGetSelectedWidgets(self):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
246 return [self.getWidget(self._xmlui_selected_row, col) for col in range(self.columns)]
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
247
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
248 def _xmluiGetSelectedIndex(self):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
249 try:
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
250 return self._xmlui_rows_idx[self._xmlui_selected_row]
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
251 except TypeError:
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
252 return None
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
253
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
254 def _xmluiOnSelect(self, callback):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
255 self._xmlui_select_cb = callback
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
256
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
257
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
258 class PairsContainer(xmlui.PairsContainer, Grid):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
259
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
260 def __init__(self, _xmlui_parent):
247
fe83837d3491 browser_side: removed some trailing spaces
Goffi <goffi@goffi.org>
parents: 229
diff changeset
261 Grid.__init__(self, 0, 0)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
262 self.row = 0
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
263 self.col = 0
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
264
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
265 def _xmluiAppend(self, widget):
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
266 if self.col == 0:
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
267 self.resize(self.row + 1, 2)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
268 self.setWidget(self.row, self.col, widget)
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
269 self.col += 1
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
270 if self.col == 2:
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
271 self.row += 1
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
272 self.col = 0
247
fe83837d3491 browser_side: removed some trailing spaces
Goffi <goffi@goffi.org>
parents: 229
diff changeset
273
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
274
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
275 class TabsContainer(LiberviaContainer, xmlui.TabsContainer, TabPanel):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
276
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
277 def __init__(self, _xmlui_parent):
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
278 TabPanel.__init__(self)
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
279 self.setStyleName('liberviaTabPanel')
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
280
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
281 def _xmluiAddTab(self, label):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
282 tab_panel = VerticalContainer(self)
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
283 self.add(tab_panel, label)
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
284 if len(self.getChildren()) == 1:
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
285 self.selectTab(0)
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
286 return tab_panel
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
287
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
288
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
289 class VerticalContainer(LiberviaContainer, xmlui.VerticalContainer, VerticalPanel):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
290 __bases__ = (LiberviaContainer, xmlui.VerticalContainer, VerticalPanel)
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
291
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
292 def __init__(self, _xmlui_parent):
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
293 VerticalPanel.__init__(self)
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
294
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
295
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
296 ## Dialogs ##
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
297
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
298
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
299 class Dlg(object):
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
300
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
301 def _xmluiShow(self):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
302 self.show()
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
303
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
304 def _xmluiClose(self):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
305 pass
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
306
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
307
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
308 class MessageDialog(Dlg, xmlui.MessageDialog, dialog.InfoDialog):
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
309
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
310 def __init__(self, _xmlui_parent, title, message, level):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
311 #TODO: level is not managed
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
312 Dlg.__init__(self)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
313 xmlui.MessageDialog.__init__(self, _xmlui_parent)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
314 dialog.InfoDialog.__init__(self, title, message, self._xmluiValidated())
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
315
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
316
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
317 class NoteDialog(xmlui.NoteDialog, MessageDialog):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
318 # TODO: separate NoteDialog
247
fe83837d3491 browser_side: removed some trailing spaces
Goffi <goffi@goffi.org>
parents: 229
diff changeset
319
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
320 def __init__(self, _xmlui_parent, title, message, level):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
321 xmlui.NoteDialog.__init__(self, _xmlui_parent)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
322 MessageDialog.__init__(self, _xmlui_parent, title, message, level)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
323
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
324
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
325 class ConfirmDialog(xmlui.ConfirmDialog, Dlg, dialog.ConfirmDialog):
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
326
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
327 def __init__(self, _xmlui_parent, title, message, level):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
328 #TODO: level is not managed
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
329 xmlui.ConfirmDialog.__init__(self, _xmlui_parent)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
330 print "self.parent = %s" % self._xmlui_parent
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
331 Dlg.__init__(self)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
332 dialog.ConfirmDialog.__init__(self, self.answered, message, title)
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
333
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
334 def answered(self, validated):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
335 if validated:
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
336 self._xmluiValidated()
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
337 else:
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
338 self._xmluiCancelled()
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
339
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
340
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
341 class FileDialog(xmlui.FileDialog, Dlg):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
342 #TODO:
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
343
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
344 def __init__(self, _xmlui_parent, title, message, level, filetype):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
345 raise NotImplementedError("FileDialog is not implemented in Libervia yet")
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
346
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
347
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
348 class GenericFactory(object):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
349 # XXX: __getattr__ doens't work here with pyjamas for an unknown reason
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
350 # so an introspection workaround is used
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
351
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
352 def __init__(self):
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
353
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
354 for name, cls in globals().items():
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
355 if name.endswith("Widget") or name.endswith("Container") or name.endswith("Dialog"):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
356 log.info("registering: %s" % name)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
357 def createCreater(cls):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
358 return lambda *args, **kwargs: self._genericCreate(cls, *args, **kwargs)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
359 setattr(self, "create%s" % name, createCreater(cls))
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
360
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
361 def _genericCreate(self, cls, *args, **kwargs):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
362 instance = cls(*args, **kwargs)
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
363 return instance
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
364
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
365 # def __getattr__(self, attr):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
366 # if attr.startswith("create"):
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
367 # cls = globals()[attr[6:]]
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
368 # cls._xmlui_main = self._xmlui_main
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
369 # return cls
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
370
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
371
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
372 class WidgetFactory(GenericFactory):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
373
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
374 def _genericCreate(self, cls, *args, **kwargs):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
375 instance = GenericFactory._genericCreate(self, cls, *args, **kwargs)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
376 instance._xmlui_main = self._xmlui_main
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
377 return instance
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
378
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
379 class LiberviaXMLUIBase(object):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
380
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
381 def _xmluiLaunchAction(self, action_id, data):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
382 self.host.launchAction(action_id, data)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
383
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
384
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
385 class XMLUIPanel(LiberviaXMLUIBase, xmlui.XMLUIPanel, VerticalPanel):
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
386 widget_factory = WidgetFactory()
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
387
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
388 def __init__(self, host, parsed_xml, title=None, flags=None):
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
389 self.widget_factory._xmlui_main = self
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
390 VerticalPanel.__init__(self)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
391 self.setSize('100%', '100%')
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
392 xmlui.XMLUIPanel.__init__(self, host, parsed_xml, title, flags)
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
393
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
394 def setCloseCb(self, close_cb):
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
395 self.close_cb = close_cb
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
396
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
397 def _xmluiClose(self):
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
398 if self.close_cb:
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
399 self.close_cb()
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
400 else:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 430
diff changeset
401 log.warning("no close method defined")
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
402
337
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
403 def _xmluiSetParam(self, name, value, category):
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
404 self.host.bridge.call('setParam', None, name, value, category)
ea1be522ba88 browser side: XMLUI fixes:
Goffi <goffi@goffi.org>
parents: 335
diff changeset
405
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
406 def constructUI(self, parsed_dom):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
407 super(XMLUIPanel, self).constructUI(parsed_dom)
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
408 self.add(self.main_cont)
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
409 self.setCellHeight(self.main_cont, '100%')
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
410 if self.type == 'form':
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
411 hpanel = HorizontalPanel()
392
f539f6f8ee9c browser_side: standardize the dialogs size and buttons display:
souliane <souliane@mailoo.org>
parents: 390
diff changeset
412 hpanel.setStyleName('marginAuto')
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
413 hpanel.add(Button('Submit', self.onFormSubmitted))
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
414 if not 'NO_CANCEL' in self.flags:
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
415 hpanel.add(Button('Cancel', self.onFormCancelled))
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
416 self.add(hpanel)
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
417 elif self.type == 'param':
451
1a0cec9b0f1e better PEP-8 compliance
souliane <souliane@mailoo.org>
parents: 449
diff changeset
418 assert(isinstance(self.children[0][0], TabPanel))
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
419 hpanel = HorizontalPanel()
392
f539f6f8ee9c browser_side: standardize the dialogs size and buttons display:
souliane <souliane@mailoo.org>
parents: 390
diff changeset
420 hpanel.add(Button('Save', self.onSaveParams))
335
e8c26e24a6c7 browser side: refactored XMLUI to use the new sat_frontends.tools.xmlui.XMLUI class, first draft
Goffi <goffi@goffi.org>
parents: 325
diff changeset
421 hpanel.add(Button('Cancel', lambda ignore: self._xmluiClose()))
143
03c22ddd7c94 browser side: XMLUI implentation
Goffi <goffi@goffi.org>
parents:
diff changeset
422 self.add(hpanel)
500
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
423
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
424 def show(self):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
425 options = ['NO_CLOSE'] if self.type == C.XMLUI_FORM else []
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
426 _dialog = dialog.GenericDialog(self.title, self, options=options)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
427 self.setCloseCb(_dialog.close)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
428 _dialog.show()
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
429
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
430
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
431 class XMLUIDialog(LiberviaXMLUIBase, xmlui.XMLUIDialog):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
432 dialog_factory = GenericFactory()
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
433
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
434 def __init__(self, host, parsed_dom, title = None, flags = None):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
435 xmlui.XMLUIDialog.__init__(self, host, parsed_dom, title, flags)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
436
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
437 xmlui.registerClass(xmlui.CLASS_PANEL, XMLUIPanel)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
438 xmlui.registerClass(xmlui.CLASS_DIALOG, XMLUIDialog)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
439
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
440 def create(*args, **kwargs):
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
441 dom = nativedom.NativeDOM()
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
442 kwargs['dom_parse'] = lambda xml_data: dom.parseString(xml_data)
67a4e8383b70 browser side (XMLUI): XMLUI update to follow core changes:
Goffi <goffi@goffi.org>
parents: 489
diff changeset
443 return xmlui.create(*args, **kwargs)