summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorXisco Fauli <anistenis@gmail.com>2011-06-28 21:23:50 +0200
committerXisco Fauli <anistenis@gmail.com>2011-06-28 21:23:50 +0200
commit6747e454f04db5ee60475d2d1b101094b5a089c0 (patch)
treebbb4e123781b6aa6a5076571b2ab784d84be38c6 /wizards
parentf09cc2981eaf054cdb2450576ae6b435ea6f4cfb (diff)
Load preview configuration
Diffstat (limited to 'wizards')
-rw-r--r--wizards/com/sun/star/wizards/common/ConfigGroup.py73
-rw-r--r--wizards/com/sun/star/wizards/common/Configuration.py13
-rw-r--r--wizards/com/sun/star/wizards/document/OfficeDocument.py9
-rw-r--r--wizards/com/sun/star/wizards/ui/event/DataAwareFields.py5
-rw-r--r--wizards/com/sun/star/wizards/ui/event/UnoDataAware.py1
5 files changed, 37 insertions, 64 deletions
diff --git a/wizards/com/sun/star/wizards/common/ConfigGroup.py b/wizards/com/sun/star/wizards/common/ConfigGroup.py
index a5824e803..b7715ac0e 100644
--- a/wizards/com/sun/star/wizards/common/ConfigGroup.py
+++ b/wizards/com/sun/star/wizards/common/ConfigGroup.py
@@ -1,74 +1,39 @@
from ConfigNode import *
from Configuration import Configuration
import traceback
+import inspect
class ConfigGroup(ConfigNode):
+ root = None
+
def writeConfiguration(self, configurationView, param):
- for i in dir(self):
- if i.startswith(param):
- try:
- self.writeField(i, configurationView, param)
- except Exception, ex:
- print "Error writing field:" + i
- traceback.print_exc()
+ 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):]
- field = getattr(self,field)
-
- if isinstance(field, ConfigNode):
- pass
- #print configView
- #childView = Configuration.addConfigNode(configView, propertyName)
- #self.writeConfiguration(childView, prefix)
+ child = getattr(self, field)
+ if isinstance(child, ConfigNode):
+ child.setRoot(self.root)
+ child.writeConfiguration(configView.getByName(propertyName),
+ prefix)
else:
- #print type(field)
- Configuration.Set(self.convertValue(field), propertyName,
- configView)
+ configView.setHierarchicalPropertyValue(propertyName,getattr(self,field))
- '''
- convert the primitive type value of the
- given Field object to the corresponding
- Java Object value.
- @param field
- @return the value of the field as a Object.
- @throws IllegalAccessException
- '''
-
- def convertValue(self, field):
- if isinstance(field,bool):
- return bool(field)
- elif isinstance(field,int):
- return int(field)
-
- def readConfiguration(self, configurationView, param):
- for i in dir(self):
- if i.startswith(param):
- try:
- self.readField( i, configurationView, param)
- except Exception, ex:
- print "Error reading field: " + i
- traceback.print_exc()
def readConfiguration(self, configurationView, param):
- for i in dir(self):
- if i.startswith(param):
- try:
- self.readField( i, configurationView, param)
- except Exception, ex:
- print "Error reading field: " + i
- traceback.print_exc()
+ 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)
- fieldType = type(child)
- if type(ConfigNode) == fieldType:
+ if isinstance(child, ConfigNode):
child.setRoot(self.root)
- child.readConfiguration(Configuration.getNode(propertyName, configView),
+ child.readConfiguration(configView.getByName(propertyName),
prefix)
- field.set(this, Configuration.getString(propertyName, configView))
-
- def setRoot(self, newRoot):
- self.root = newRoot
+ else:
+ setattr(self,field,configView.getByName(propertyName))
diff --git a/wizards/com/sun/star/wizards/common/Configuration.py b/wizards/com/sun/star/wizards/common/Configuration.py
index 96385bfab..d11f1c5ce 100644
--- a/wizards/com/sun/star/wizards/common/Configuration.py
+++ b/wizards/com/sun/star/wizards/common/Configuration.py
@@ -24,7 +24,7 @@ class Configuration(object):
@classmethod
def Set(self, value, name, parent):
- parent.setHierarchicalPropertyValue(name, value)
+ setattr(parent, name, value)
'''
@param name
@@ -131,13 +131,12 @@ class Configuration(object):
if configView is None:
return configView.getByName(name)
else:
- print configView
+ # the new element is the result !
+ print type(configView)
+ newNode = configView.createInstance()
# insert it - this also names the element
- try:
- configView.insertByName(name, configView.createInstance())
- except Exception,e:
- traceback.print_exc()
- #return newNode
+ configView.insertByName(name, newNode)
+ return newNode
@classmethod
def removeNode(self, configView, name):
diff --git a/wizards/com/sun/star/wizards/document/OfficeDocument.py b/wizards/com/sun/star/wizards/document/OfficeDocument.py
index e2636d026..f053baebe 100644
--- a/wizards/com/sun/star/wizards/document/OfficeDocument.py
+++ b/wizards/com/sun/star/wizards/document/OfficeDocument.py
@@ -7,6 +7,8 @@ from com.sun.star.awt import WindowDescriptor
from com.sun.star.awt import Rectangle
import unohelper
+from com.sun.star.task import ErrorCodeIOException
+
#Window Constants
com_sun_star_awt_WindowAttribute_BORDER \
= uno.getConstantByName( "com.sun.star.awt.WindowAttribute.BORDER" )
@@ -199,9 +201,12 @@ class OfficeDocument(object):
unohelper.absolutize(
unohelper.systemPathToFileUrl(sPath),
unohelper.systemPathToFileUrl(sFile)),
- tuple(oStoreProperties))
-
+ tuple(oStoreProperties))
+ return True
+ except ErrorCodeIOException:
return True
+ #There's a bug here, fix later
+ pass
except Exception, exception:
traceback.print_exc()
return False
diff --git a/wizards/com/sun/star/wizards/ui/event/DataAwareFields.py b/wizards/com/sun/star/wizards/ui/event/DataAwareFields.py
index 80f400ded..4a8e04b6b 100644
--- a/wizards/com/sun/star/wizards/ui/event/DataAwareFields.py
+++ b/wizards/com/sun/star/wizards/ui/event/DataAwareFields.py
@@ -34,8 +34,11 @@ class DataAwareFields(object):
return self.__ConvertedStringValue(fieldname, value)
elif isinstance(f,int):
return self.__IntFieldValue(fieldname, value)
+ elif isinstance(f,float):
+ pass
+ #return self.__IntFieldValue(fieldname, value)
else:
- return SimpleFieldValue(f)
+ return self.__IntFieldValue(fieldname, value)
except AttributeError, ex:
traceback.print_exc()
diff --git a/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py b/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py
index cca27ae5f..9e4a456a9 100644
--- a/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py
+++ b/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py
@@ -134,6 +134,7 @@ class UnoDataAware(DataAware):
return self.__attachTextControl(
data, prop, unoControl, listener, "Time", field, 0)
+ @classmethod
def attachNumericControl(self, data, prop, unoControl, listener, field):
return self.__attachTextControl(
data, prop, unoControl, listener, "Value", field, float(0))