summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorXisco Fauli <anistenis@gmail.com>2011-06-30 01:56:32 +0200
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2011-08-18 02:13:22 +0200
commitdeea0a222283c8ab4faa88d852de950a7639ed4d (patch)
treeb58018ab7950dce8a43ebafb7fe8d80e1628431f /wizards
parentf9bb17f30fa42d2dbeba6c6d6d2baf44c51867ca (diff)
Remember last template and clean ui/event/
Diffstat (limited to 'wizards')
-rw-r--r--wizards/com/sun/star/wizards/ui/event/DataAware.py39
-rw-r--r--wizards/com/sun/star/wizards/ui/event/DataAwareField.py35
-rw-r--r--wizards/com/sun/star/wizards/ui/event/RadioDataAware.py10
-rw-r--r--wizards/com/sun/star/wizards/ui/event/UnoDataAware.py89
4 files changed, 20 insertions, 153 deletions
diff --git a/wizards/com/sun/star/wizards/ui/event/DataAware.py b/wizards/com/sun/star/wizards/ui/event/DataAware.py
index b0360ebe74b6..c2771d5a47c1 100644
--- a/wizards/com/sun/star/wizards/ui/event/DataAware.py
+++ b/wizards/com/sun/star/wizards/ui/event/DataAware.py
@@ -28,9 +28,9 @@ class DataAware(object):
@param value_
'''
- def __init__(self, dataObject_, value_):
+ def __init__(self, dataObject_, field_):
self._dataObject = dataObject_
- self._value = value_
+ self._field = field_
'''
sets the given value to the UI control
@@ -55,7 +55,7 @@ class DataAware(object):
'''
def updateUI(self):
- data = self._value.get(self._dataObject)
+ data = getattr(self._dataObject, self._field)
ui = self.getFromUI()
if data is not ui:
try:
@@ -71,38 +71,17 @@ class DataAware(object):
def updateData(self):
try:
- data = self._value.get(self._dataObject)
+ data = getattr(self._dataObject, self._field)
ui = self.getFromUI()
if data is not ui:
- self._value.Set(ui, self._dataObject)
+ if isinstance(ui,tuple):
+ #Selected Element listbox
+ ui = ui[0]
+ setattr(self._dataObject, self._field, ui)
except Exception:
traceback.print_exc()
'''
- compares the two given objects.
- This method is null safe and returns true also if both are null...
- If both are arrays, treats them as array of short and compares them.
- @param a first object to compare
- @param b second object to compare.
- @return true if both are null or both are equal.
- '''
-
- def equals(self, a, b):
- if not a and not b :
- return True
-
- if not a or not b:
- return False
-
- if a.getClass().isArray():
- if b.getClass().isArray():
- return Arrays.equals(a, b)
- else:
- return False
-
- return a.equals(b)
-
- '''
given a collection containing DataAware objects,
calls updateUI() on each memebr of the collection.
@param dataAwares a collection containing DataAware objects.
@@ -124,7 +103,7 @@ class DataAware(object):
def setDataObject(self, dataObject, updateUI):
if dataObject is not None:
- if not (type(self._value) is not
+ if not (type(self._field) is not
type(dataObject)):
raise ClassCastException (
"can not cast new DataObject to original Class")
diff --git a/wizards/com/sun/star/wizards/ui/event/DataAwareField.py b/wizards/com/sun/star/wizards/ui/event/DataAwareField.py
deleted file mode 100644
index 8f8b64fed08c..000000000000
--- a/wizards/com/sun/star/wizards/ui/event/DataAwareField.py
+++ /dev/null
@@ -1,35 +0,0 @@
-import traceback
-from DataAware import *
-import uno
-
-class DataAwareField(object):
-
- def __init__(self, field, convertTo):
- self.convertTo = convertTo
- self.field = field
-
- def get(self, target):
- try:
- i = getattr(target, self.field)
- if isinstance(self.convertTo, bool):
- if i:
- return True
- else:
- return False
- elif isinstance(self.convertTo,int):
- return int(i)
- elif isinstance(self.convertTo,str):
- return str(i)
- elif self.convertTo.type == uno.Any("short",0).type:
- return uno.Any("[]short",(i,))
- else:
- raise AttributeError(
- "Cannot convert int value to given type (" + \
- str(type(self.convertTo)) + ").")
-
- except AttributeError, ex:
- traceback.print_exc()
- return None
-
- def Set(self, value, target):
- setattr(target, self.field, value)
diff --git a/wizards/com/sun/star/wizards/ui/event/RadioDataAware.py b/wizards/com/sun/star/wizards/ui/event/RadioDataAware.py
index 12f6e94f7a10..457f7580b883 100644
--- a/wizards/com/sun/star/wizards/ui/event/RadioDataAware.py
+++ b/wizards/com/sun/star/wizards/ui/event/RadioDataAware.py
@@ -1,5 +1,4 @@
from DataAware import *
-from DataAwareField import DataAwareField
from UnoDataAware import *
import time
'''
@@ -32,13 +31,8 @@ class RadioDataAware(DataAware):
return -1
@classmethod
- def attachRadioButtons(self, data, dataProp, buttons, field):
- if field:
- aux = DataAwareField(dataProp, 0)
- else:
- aux = DataAware.PropertyValue(dataProp, data)
-
- da = RadioDataAware(data, aux , buttons)
+ 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))
diff --git a/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py b/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py
index c12a81c33f35..7c3436caa59c 100644
--- a/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py
+++ b/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py
@@ -1,5 +1,4 @@
from DataAware import *
-from DataAwareField import DataAwareField
from common.Helper import *
'''
@@ -15,79 +14,25 @@ For those controls, static convenience methods are offered, to simplify use.
class UnoDataAware(DataAware):
- def __init__(self, dataObject, value, unoObject_, unoPropName_):
- super(UnoDataAware,self).__init__(dataObject, value)
+ def __init__(self, dataObject, field, unoObject_, unoPropName_, isShort=False):
+ super(UnoDataAware,self).__init__(dataObject, field)
self.unoControl = unoObject_
self.unoModel = self.unoControl.Model
self.unoPropName = unoPropName_
- self.disableObjects = range(0)
- self.inverse = False
-
- def setInverse(self, i):
- self.inverse = i
-
- def enableControls(self, value):
- b = getBoolean(value)
- if self.inverse:
- if b.booleanValue():
- b = False
- else:
- b = True
-
- i = 0
- while i < self.disableObjects.length:
- setEnabled(self.disableObjects[i], b)
- i += 1
+ self.isShort = isShort
def setToUI(self, value):
+ if self.isShort:
+ value = uno.Any("[]short", (value,))
Helper.setUnoPropertyValue(self.unoModel, self.unoPropName, value)
- '''
- Try to get from an arbitrary object a boolean value.
- Null returns False;
- A Boolean object returns itself.
- An Array returns true if it not empty.
- An Empty String returns False.
- everything else returns a True.
- @param value
- @return
- '''
-
- def getBoolean(self, value):
- if value == None:
- return False
-
- if isinstance(value, bool):
- return value
- elif value.getClass().isArray():
- if value.length != 0:
- return True
- else:
- return False
- elif value.equals(""):
- return False
- elif isinstance(value, int):
- if value == 0:
- return True
- else:
- return False
- else:
- return True
-
- def disableControls(self, controls):
- self.disableObjects = controls
-
def getFromUI(self):
return Helper.getUnoPropertyValue(self.unoModel, self.unoPropName)
@classmethod
def __attachTextControl(
self, data, prop, unoText, unoProperty, field, value):
- if field:
- aux = DataAwareField(prop, value)
- else:
- aux = DataAware.PropertyValue (prop, data)
- uda = UnoDataAware(data, aux, unoText, unoProperty)
+ uda = UnoDataAware(data, prop, unoText, unoProperty)
method = getattr(uda,"updateData")
unoText.addTextListener(TextListenerProcAdapter(method))
return uda
@@ -113,33 +58,17 @@ class UnoDataAware(DataAware):
@classmethod
def attachCheckBox(self, data, prop, checkBox, field):
- if field:
- aux = DataAwareField(prop, 0)
- else:
- aux = DataAware.PropertyValue (prop, data)
- uda = UnoDataAware(data, aux , checkBox, PropertyNames.PROPERTY_STATE)
+ uda = UnoDataAware(data, prop, checkBox, PropertyNames.PROPERTY_STATE)
method = getattr(uda,"updateData")
checkBox.addItemListener(ItemListenerProcAdapter(method))
return uda
def attachLabel(self, data, prop, label, field):
- if field:
- aux = DataAwareField(prop, "")
- else:
- aux = DataAware.PropertyValue (prop, data)
- return UnoDataAware(data, aux, label, PropertyNames.PROPERTY_LABEL)
+ return UnoDataAware(data, prop, label, PropertyNames.PROPERTY_LABEL)
@classmethod
def attachListBox(self, data, prop, listBox, field):
- if field:
- aux = DataAwareField(prop, uno.Any("short",0))
- else:
- aux = DataAware.PropertyValue (prop, data)
- uda = UnoDataAware(data, aux, listBox, "SelectedItems")
+ uda = UnoDataAware(data, prop, listBox, "SelectedItems", True)
method = getattr(uda,"updateData")
listBox.addItemListener(ItemListenerProcAdapter(method))
return uda
-
- def setEnabled(self, control, enabled):
- Helper.setUnoPropertyValue(
- getModel(control), PropertyNames.PROPERTY_ENABLED, enabled)