summaryrefslogtreecommitdiff
path: root/wizards/com/sun/star/wizards/ui/UnoDialog2.py
blob: 45b6249a942f331b9587a1613ee5ad1ca6aa1884 (plain)
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
from UnoDialog import *
from ui.event.CommonListener import *
from common.Desktop import Desktop

'''
This class contains convenience methods for inserting components to a dialog.
It was created for use with the automatic conversion of Basic XML Dialog
description files to a Java class which builds
the same dialog through the UNO API.<br/>
It uses an Event-Listener method, which calls a method through reflection
wenn an event on a component is trigered.
see the classes CommonListener for details
'''

class UnoDialog2(UnoDialog):

    '''
    Override this method to return another listener.
    @return
    '''

    def __init__(self, xmsf):
        super(UnoDialog2,self).__init__(xmsf,(), ())
        ControlList = {}

    def insertButton(
        self, sName, actionPerformed, sPropNames, oPropValues, listener):
        xButton = self.insertControlModel(
            "com.sun.star.awt.UnoControlButtonModel",
            sName, sPropNames, oPropValues)
        if actionPerformed is not None:
            actionPerformed = getattr(listener, actionPerformed)
            xButton.addActionListener(
                ActionListenerProcAdapter(actionPerformed))

        return xButton

    def insertImageButton(
            self, sName, actionPerformed, sPropNames, oPropValues, listener):
        xButton = self.insertControlModel(
            "com.sun.star.awt.UnoControlButtonModel",
            sName, sPropNames, oPropValues)
        if actionPerformed is not None:
            actionPerformed = getattr(listener, actionPerformed)
            xButton.addActionListener(
                ActionListenerProcAdapter(actionPerformed))

        return xButton

    def insertCheckBox(
        self, sName, itemChanged, sPropNames, oPropValues, listener):
        xCheckBox = self.insertControlModel(
            "com.sun.star.awt.UnoControlCheckBoxModel",
            sName, sPropNames, oPropValues)
        if itemChanged is not None:
            itemChanged = getattr(listener, itemChanged)
            xCheckBox.addItemListener(ItemListenerProcAdapter(itemChanged))

        return xCheckBox

    def insertComboBox(
        self, sName, actionPerformed, itemChanged,
        textChanged, sPropNames, oPropValues, listener):
        xComboBox = self.insertControlModel(
        "com.sun.star.awt.UnoControlComboBoxModel",
        sName, sPropNames, oPropValues)
        if actionPerformed is not None:
            actionPerformed = getattr(listener, actionPerformed)
            xComboBox.addActionListener(
                ActionListenerProcAdapter(actionPerformed))

        if itemChanged is not None:
            itemChanged = getattr(listener, itemChanged)
            xComboBox.addItemListener(ItemListenerProcAdapter(itemChanged))

        if textChanged is not None:
            textChanged = getattr(listener, textChanged)
            xComboBox.addTextListener(TextListenerProcAdapter(textChanged))

        return xComboBox

    def insertListBox(
        self, sName, actionPerformed, itemChanged,
        sPropNames, oPropValues, listener):
        xListBox = self.insertControlModel(
            "com.sun.star.awt.UnoControlListBoxModel",
            sName, sPropNames, oPropValues)

        if itemChanged is not None:
            itemChanged = getattr(listener, itemChanged)
            xListBox.addItemListener(ItemListenerProcAdapter(itemChanged))

        return xListBox

    def insertRadioButton(
        self, sName, itemChanged, sPropNames, oPropValues, listener):
        xRadioButton = self.insertControlModel(
            "com.sun.star.awt.UnoControlRadioButtonModel",
            sName, sPropNames, oPropValues)
        if itemChanged is not None:
            itemChanged = getattr(listener, itemChanged)
            xRadioButton.addItemListener(
                ItemListenerProcAdapter(itemChanged))

        return xRadioButton

    def insertTitledBox(self, sName, sPropNames, oPropValues):
        oTitledBox = self.insertControlModel(
            "com.sun.star.awt.UnoControlGroupBoxModel",
            sName, sPropNames, oPropValues)
        return oTitledBox

    def insertTextField(
        self, sName, sTextChanged, sPropNames, oPropValues, listener):
        return self.insertEditField(
            sName, sTextChanged, "com.sun.star.awt.UnoControlEditModel",
            sPropNames, oPropValues, listener)

    def insertImage(self, sName, sPropNames, oPropValues):
        return self.insertControlModel(
            "com.sun.star.awt.UnoControlImageControlModel",
            sName, sPropNames, oPropValues)

    def insertInfoImage(self, _posx, _posy, _iStep):
        xImgControl = self.insertImage(
            Desktop.getUniqueName(self.xDialogModel, "imgHint"),
            ("Border",
                PropertyNames.PROPERTY_HEIGHT,
                PropertyNames.PROPERTY_IMAGEURL,
                PropertyNames.PROPERTY_POSITION_X,
                PropertyNames.PROPERTY_POSITION_Y, "ScaleImage",
                PropertyNames.PROPERTY_STEP,
                PropertyNames.PROPERTY_WIDTH),
            (0, 10, UIConsts.INFOIMAGEURL, _posx, _posy, False, _iStep, 10))
        return xImgControl

    '''
    This method is used for creating Edit, Currency, Date, Formatted,
    Pattern, File and Time edit components.
    '''

    def insertEditField(
        self, sName, sTextChanged, sModelClass,
        sPropNames, oPropValues, listener):
        xField = self.insertControlModel(sModelClass,
            sName, sPropNames, oPropValues)
        if sTextChanged is not None:
            sTextChanged = getattr(listener, sTextChanged)
            xField.addTextListener(TextListenerProcAdapter(sTextChanged))
        return xField

    def insertFileControl(
        self, sName, sTextChanged, sPropNames, oPropValues, listener):
        return self.insertEditField(sName, sTextChanged,
            "com.sun.star.awt.UnoControlFileControlModel",
            sPropNames, oPropValues, listener)

    def insertCurrencyField(
        self, sName, sTextChanged, sPropNames, oPropValues, listener):
        return self.insertEditField(
            sName, sTextChanged,
            "com.sun.star.awt.UnoControlCurrencyFieldModel",
            sPropNames, oPropValues, listener)

    def insertDateField(
        self, sName, sTextChanged, sPropNames, oPropValues, listener):
        return self.insertEditField(
            sName, sTextChanged,
            "com.sun.star.awt.UnoControlDateFieldModel",
            sPropNames, oPropValues, listener)

    def insertNumericField(
        self, sName, sTextChanged, sPropNames, oPropValues, listener):
        return self.insertEditField(
            sName, sTextChanged,
            "com.sun.star.awt.UnoControlNumericFieldModel",
            sPropNames, oPropValues, listener)

    def insertTimeField(
        self, sName, sTextChanged, sPropNames, oPropValues, listener):
        return self.insertEditField(
            sName, sTextChanged,
            "com.sun.star.awt.UnoControlTimeFieldModel",
            sPropNames, oPropValues, listener)

    def insertPatternField(
        self, sName, sTextChanged, oPropValues, listener):
        return self.insertEditField(sName, sTextChanged,
            "com.sun.star.awt.UnoControlPatternFieldModel",
            sPropNames, oPropValues, listener)

    def insertFormattedField(
        self, sName, sTextChanged, sPropNames, oPropValues, listener):
        return self.insertEditField(
            sName, sTextChanged,
            "com.sun.star.awt.UnoControlFormattedFieldModel",
            sPropNames, oPropValues, listener)

    def insertFixedLine(self, sName, sPropNames, oPropValues):
        oLine = self.insertControlModel(
            "com.sun.star.awt.UnoControlFixedLineModel",
            sName, sPropNames, oPropValues)
        return oLine

    def insertLabel(self, sName, sPropNames, oPropValues):
        oFixedText = self.insertControlModel(
            "com.sun.star.awt.UnoControlFixedTextModel",
            sName, sPropNames, oPropValues)
        return oFixedText

    def insertScrollBar(self, sName, sPropNames, oPropValues,
            iControlKey, listener):
        oScrollBar = self.insertControlModel(
            "com.sun.star.awt.UnoControlScrollBarModel",
            sName, sPropNames, oPropValues)
        if listener is not None:
            method = getattr(listener, "scrollControls")
            oScrollBar.addAdjustmentListener(
                AdjustmentListenerProcAdapter(method))
        if self.ControlList is not None:
            self.ControlList[sName] = iControlKey
        return oScrollBar

    def insertProgressBar(self, sName, sPropNames, oPropValues):
        oProgressBar = self.insertControlModel(
            "com.sun.star.awt.UnoControlProgressBarModel",
            sName, sPropNames, oPropValues)
        return oProgressBar

    def insertGroupBox(self, sName, sPropNames, oPropValues):
        oGroupBox = self.insertControlModel(
            "com.sun.star.awt.UnoControlGroupBoxModel",
            sName, sPropNames, oPropValues)
        return oGroupBox

    def showMessageBox(self, windowServiceName, windowAttribute, MessageText):
        return SystemDialog.showMessageBox(
            xMSF, self.xControl.Peer,
            windowServiceName, windowAttribute, MessageText)