summaryrefslogtreecommitdiff
path: root/wizards/com/sun/star/wizards/common/ConfigGroup.py
blob: 2e0fd943469939f678426169f49b3d0d0fce64c8 (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
from ConfigNode import *
from Configuration import Configuration
import traceback
import inspect

class ConfigGroup(ConfigNode):

    def writeConfiguration(self, configurationView, param):
        for name,data in inspect.getmembers(self):
            if name.startswith(param):
                self.writeField( name, configurationView, param)

    def writeField(self, field, configView, prefix):
        propertyName = field[len(prefix):]
        child = getattr(self, field)
        if isinstance(child, ConfigNode):
            child.writeConfiguration(configView.getByName(propertyName),
                prefix)
        else:
            setattr(configView,propertyName,getattr(self,field))

    def readConfiguration(self, configurationView, param):
        for name,data in inspect.getmembers(self):
            if name.startswith(param):
                self.readField( name, configurationView, param)

    def readField(self, field, configView, prefix):
        propertyName = field[len(prefix):]
        child = getattr(self, field)
        if isinstance(child, ConfigNode):
            child.root = self.root
            child.readConfiguration(configView.getByName(propertyName),
                prefix)
        else:
            setattr(self,field,configView.getByName(propertyName))