summaryrefslogtreecommitdiff
path: root/wizards/com/sun/star/wizards/ui/event/RadioDataAware.py
blob: 31d37407c4e73c1ce611bfd79f59b610c7c6905e (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
from DataAware import *
from UnoDataAware import *
import time
'''
@author rpiterman
To change the template for this generated type comment go to
Window>Preferences>Java>Code Generation>Code and Comments
'''

class RadioDataAware(DataAware):

    def __init__(self, data, value, radioButtons):
        super(RadioDataAware,self).__init__(data, value)
        self.radioButtons = radioButtons

    def setToUI(self, value):
        selected = int(value)
        if selected == -1:
            i = 0
            while i < self.radioButtons.length:
                self.radioButtons[i].State = False
                i += 1
        else:
            self.radioButtons[selected].State = True

    def getFromUI(self):
        for index, workwith in enumerate(self.radioButtons):
            if workwith.State:
                return index

        return -1

    @classmethod
    def attachRadioButtons(self, data, prop, buttons, field):
        da = RadioDataAware(data, prop, buttons)
        method = getattr(da,"updateData")
        for i in da.radioButtons:
            i.addItemListener(ItemListenerProcAdapter(method))
        return da