summaryrefslogtreecommitdiff
path: root/wizards/com/sun/star/wizards/ui/event
diff options
context:
space:
mode:
authorXisco Fauli <anistenis@gmail.com>2011-09-24 12:59:08 +0200
committerXisco Fauli <anistenis@gmail.com>2011-09-24 12:59:08 +0200
commit0f7d6910567f1df22f1706623043554989216a7c (patch)
treedd743bac473b0e8822bb2c3f4038b922c863a778 /wizards/com/sun/star/wizards/ui/event
parentcf16ef6c250a2755155a02f24bad861b35a1f92b (diff)
Remote the python code for now.
The reason I delete it is because this code is not used yet. I still keep working in the feature branch, so when i'll finish there i'll merge it into master. It doesn't make sense to have it in master for now
Diffstat (limited to 'wizards/com/sun/star/wizards/ui/event')
-rw-r--r--wizards/com/sun/star/wizards/ui/event/CommonListener.py124
-rw-r--r--wizards/com/sun/star/wizards/ui/event/DataAware.py114
-rw-r--r--wizards/com/sun/star/wizards/ui/event/ListModelBinder.py75
-rw-r--r--wizards/com/sun/star/wizards/ui/event/RadioDataAware.py37
-rw-r--r--wizards/com/sun/star/wizards/ui/event/UnoDataAware.py84
-rw-r--r--wizards/com/sun/star/wizards/ui/event/__init__.py0
6 files changed, 0 insertions, 434 deletions
diff --git a/wizards/com/sun/star/wizards/ui/event/CommonListener.py b/wizards/com/sun/star/wizards/ui/event/CommonListener.py
deleted file mode 100644
index c94ae418036c..000000000000
--- a/wizards/com/sun/star/wizards/ui/event/CommonListener.py
+++ /dev/null
@@ -1,124 +0,0 @@
-#**********************************************************************
-#
-# Danny.OOo.Listeners.ListenerProcAdapters.py
-#
-# A module to easily work with OpenOffice.org.
-#
-#**********************************************************************
-# Copyright (c) 2003-2004 Danny Brewer
-# d29583@groovegarden.com
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See: http://www.gnu.org/licenses/lgpl.html
-#
-#**********************************************************************
-# If you make changes, please append to the change log below.
-#
-# Change Log
-# Danny Brewer Revised 2004-06-05-01
-#
-#**********************************************************************
-
-# OOo's libraries
-import unohelper
-
-from com.sun.star.awt import XActionListener
-class ActionListenerProcAdapter( unohelper.Base, XActionListener ):
- def __init__( self, oProcToCall, tParams=() ):
- self.oProcToCall = oProcToCall # a python procedure
- self.tParams = tParams # a tuple
-
-
- # oActionEvent is a com.sun.star.awt.ActionEvent struct.
- def actionPerformed( self, oActionEvent ):
- if callable( self.oProcToCall ):
- apply( self.oProcToCall )
-
-from com.sun.star.awt import XItemListener
-class ItemListenerProcAdapter( unohelper.Base, XItemListener ):
- def __init__( self, oProcToCall, tParams=() ):
- self.oProcToCall = oProcToCall # a python procedure
- self.tParams = tParams # a tuple
-
- # oItemEvent is a com.sun.star.awt.ItemEvent struct.
- def itemStateChanged( self, oItemEvent ):
- if callable( self.oProcToCall ):
- try:
- apply( self.oProcToCall)
- except:
- apply( self.oProcToCall, (oItemEvent,) + self.tParams )
-
-from com.sun.star.awt import XTextListener
-class TextListenerProcAdapter( unohelper.Base, XTextListener ):
- def __init__( self, oProcToCall, tParams=() ):
- self.oProcToCall = oProcToCall # a python procedure
- self.tParams = tParams # a tuple
-
- # oTextEvent is a com.sun.star.awt.TextEvent struct.
- def textChanged( self, oTextEvent ):
- if callable( self.oProcToCall ):
- apply( self.oProcToCall )
-
-from com.sun.star.frame import XTerminateListener
-class TerminateListenerProcAdapter( unohelper.Base, XTerminateListener ):
- def __init__( self, oProcToCall, tParams=() ):
- self.oProcToCall = oProcToCall # a python procedure
- self.tParams = tParams # a tuple
-
- def queryTermination(self, TerminateEvent):
- self.oProcToCall = getattr(self.oProcToCall,"queryTermination")
- if callable( self.oProcToCall ):
- apply( self.oProcToCall )
-
-from com.sun.star.awt import XWindowListener
-class WindowListenerProcAdapter( unohelper.Base, XWindowListener ):
- def __init__( self, oProcToCall, tParams=() ):
- self.oProcToCall = oProcToCall # a python procedure
- self.tParams = tParams # a tuple
-
- def windowShown(self, TerminateEvent):
- if callable( self.oProcToCall ):
- apply( self.oProcToCall )
-
-from com.sun.star.awt import XAdjustmentListener
-class AdjustmentListenerProcAdapter( unohelper.Base, XAdjustmentListener ):
- def __init__( self, oProcToCall, tParams=() ):
- self.oProcToCall = oProcToCall # a python procedure
- self.tParams = tParams # a tuple
-
- def adjustmentValueChanged(self, TerminateEvent):
- if callable( self.oProcToCall ):
- apply( self.oProcToCall )
-
-from com.sun.star.awt import XFocusListener
-class FocusListenerProcAdapter( unohelper.Base, XFocusListener ):
- def __init__( self, oProcToCall, tParams=() ):
- self.oProcToCall = oProcToCall # a python procedure
- self.tParams = tParams # a tuple
-
- def focusGained(self, FocusEvent):
- if callable( self.oProcToCall ):
- apply( self.oProcToCall, (FocusEvent,) + self.tParams )
-
-from com.sun.star.awt import XKeyListener
-class KeyListenerProcAdapter( unohelper.Base, XKeyListener ):
- def __init__( self, oProcToCall, tParams=() ):
- self.oProcToCall = oProcToCall # a python procedure
- self.tParams = tParams # a tuple
-
- def keyPressed(self, KeyEvent):
- if callable( self.oProcToCall ):
- apply( self.oProcToCall, (KeyEvent,) + self.tParams )
diff --git a/wizards/com/sun/star/wizards/ui/event/DataAware.py b/wizards/com/sun/star/wizards/ui/event/DataAware.py
deleted file mode 100644
index 5f4df9585587..000000000000
--- a/wizards/com/sun/star/wizards/ui/event/DataAware.py
+++ /dev/null
@@ -1,114 +0,0 @@
-from common.PropertyNames import *
-from abc import ABCMeta, abstractmethod
-import traceback
-from ui.event.CommonListener import *
-
-'''
-@author rpiterman
-DataAware objects are used to live-synchronize UI and DataModel/DataObject.
-It is used as listener on UI events, to keep the DataObject up to date.
-This class, as a base abstract class, sets a frame of functionality,
-delegating the data Object get/set methods to a Value object,
-and leaving the UI get/set methods abstract.
-Note that event listenning is *not* a part of this model.
-the updateData() or updateUI() methods should be porogramatically called.
-in child classes, the updateData() will be binded to UI event calls.
-<br><br>
-This class holds references to a Data Object and a Value object.
-The Value object "knows" how to get and set a value from the
-Data Object.
-'''
-
-class DataAware(object):
- __metaclass__ = ABCMeta
-
- '''
- creates a DataAware object for the given data object and Value object.
- @param dataObject_
- @param value_
- '''
-
- def __init__(self, dataObject_, field_):
- self._dataObject = dataObject_
- self._field = field_
-
- def enableControls(self, value):
- pass
-
- '''
- sets the given value to the UI control
- @param newValue the value to set to the ui control.
- '''
- @abstractmethod
- def setToUI (self,newValue):
- pass
-
- '''
- gets the current value from the UI control.
- @return the current value from the UI control.
- '''
-
- @abstractmethod
- def getFromUI (self):
- pass
-
- '''
- updates the UI control according to the
- current state of the data object.
- '''
-
- def updateUI(self):
- data = getattr(self._dataObject, self._field)
- ui = self.getFromUI()
- if data is not ui:
- try:
- self.setToUI(data)
- except Exception, ex:
- traceback.print_exc()
- #TODO tell user...
- self.enableControls(data)
-
- '''
- sets a new data object. Optionally
- update the UI.
- @param obj the new data object.
- @param updateUI if true updateUI() will be called.
- '''
-
- def setDataObject(self, obj, updateUI):
- if obj is not None and not isinstance(obj, type(self._field)):
- return
-
- self._dataObject = obj
-
- if updateUI:
- self.updateUI()
-
- '''
- updates the DataObject according to
- the current state of the UI control.
- '''
-
- def updateData(self):
- try:
- data = getattr(self._dataObject, self._field)
- ui = self.getFromUI()
- if data is not ui:
- if isinstance(ui,tuple):
- #Selected Element listbox
- ui = ui[0]
- setattr(self._dataObject, self._field, ui)
- self.enableControls(ui)
- except Exception:
- traceback.print_exc()
-
- '''
- given a collection containing DataAware objects,
- calls updateUI() on each memebr of the collection.
- @param dataAwares a collection containing DataAware objects.
- '''
-
- @classmethod
- def updateUIs(self, dataAwares):
- for i in dataAwares:
- i.updateUI()
diff --git a/wizards/com/sun/star/wizards/ui/event/ListModelBinder.py b/wizards/com/sun/star/wizards/ui/event/ListModelBinder.py
deleted file mode 100644
index 183bab050139..000000000000
--- a/wizards/com/sun/star/wizards/ui/event/ListModelBinder.py
+++ /dev/null
@@ -1,75 +0,0 @@
-from common.Helper import Helper
-
-class ListModelBinder(object):
-
- def __init__(self, unoListBox, listModel_):
- self.unoList = unoListBox
- self.unoListModel = unoListBox.Model
- #COMMENTED
- #self.setListModel(listModel_)
-
- def setListModel(self, newListModel):
- if self.listModel is not None:
- self.listModel.removeListDataListener(self)
-
- self.listModel = newListModel
- self.listModel.addListDataListener(this)
-
- def contentsChanged(self, lde):
- selected = getSelectedItems()
- i = lde.getIndex0()
- while i <= lde.getIndex1():
- update(i)
- i += 1
- setSelectedItems(selected)
-
- def update(self, i):
- remove(i, i)
- insert(i)
-
- def remove(self, i1, i2):
- self.unoList.removeItems(i1, i2 - i1 + 1)
-
- def insert(self, i):
- self.unoList.addItem(getItemString(i), i)
-
- def getItemString(self, i):
- return getItemString(self.listModel.getElementAt(i))
-
- def getItemString(self, item):
- return self.renderer.render(item)
-
- def getSelectedItems(self):
- return Helper.getUnoPropertyValue(self.unoListModel, "SelectedItems")
-
- def setSelectedItems(self, selected):
- Helper.setUnoPropertyValue(self.unoListModel, "SelectedItems", selected)
-
- def intervalAdded(self, lde):
- for i in xrange(lde.Index0, lde.Index1):
- insert(i)
-
- def intervalRemoved(self, lde):
- remove(lde.Index0, lde.Index1)
-
- @classmethod
- def fillList(self, xlist, items, renderer):
- Helper.setUnoPropertyValue(xlist.Model, "StringItemList", ())
- for index,item in enumerate(items):
- if item is not None:
- if renderer is not None:
- aux = renderer.render(index)
- else:
- aux = item.cp_Name
- xlist.addItem(aux, index)
-
- @classmethod
- def fillComboBox(self, xComboBox, items, renderer):
- Helper.setUnoPropertyValue(xComboBox.Model, "StringItemList", ())
- for index,item in enumerate(items):
- if item is not None:
- if renderer is not None:
- aux = renderer.render(index)
- else:
- aux = item.toString()
- xComboBox.addItem(aux, index)
diff --git a/wizards/com/sun/star/wizards/ui/event/RadioDataAware.py b/wizards/com/sun/star/wizards/ui/event/RadioDataAware.py
deleted file mode 100644
index 181662b19b5f..000000000000
--- a/wizards/com/sun/star/wizards/ui/event/RadioDataAware.py
+++ /dev/null
@@ -1,37 +0,0 @@
-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:
- for i in self.radioButtons:
- i.State = False
- 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
diff --git a/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py b/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py
deleted file mode 100644
index 483a56916afc..000000000000
--- a/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py
+++ /dev/null
@@ -1,84 +0,0 @@
-from DataAware import *
-from common.Helper import *
-
-'''
-@author rpiterman
-This class suppoprts imple cases where a UI control can
-be directly synchronized with a data property.
-Such controls are: the different text controls
-(synchronizing the "Text" , "Value", "Date", "Time" property),
-Checkbox controls, Dropdown listbox controls (synchronizing the
-SelectedItems[] property.
-For those controls, static convenience methods are offered, to simplify use.
-'''
-
-class UnoDataAware(DataAware):
-
- disableObjects = []
-
- 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.isShort = isShort
-
- def enableControls(self, value):
- for i in self.disableObjects:
- Helper.setUnoPropertyValue(
- i.Model, PropertyNames.PROPERTY_ENABLED, bool(value))
-
- def setToUI(self, value):
- if self.isShort:
- value = uno.Any("[]short", (value,))
- Helper.setUnoPropertyValue(self.unoModel, self.unoPropName, value)
-
- def getFromUI(self):
- return Helper.getUnoPropertyValue(self.unoModel, self.unoPropName)
-
- @classmethod
- def __attachTextControl(
- self, data, prop, unoText, unoProperty, field, value):
- uda = UnoDataAware(data, prop, unoText, unoProperty)
- method = getattr(uda,"updateData")
- unoText.addTextListener(TextListenerProcAdapter(method))
- return uda
-
- @classmethod
- def attachEditControl(self, data, prop, unoControl, field):
- return self.__attachTextControl(
- data, prop, unoControl, "Text", field, "")
-
- @classmethod
- def attachDateControl(self, data, prop, unoControl, field):
- return self.__attachTextControl(
- data, prop, unoControl, "Date", field, 0)
-
- @classmethod
- def attachTimeControl(self, data, prop, unoControl, field):
- return self.__attachTextControl(
- data, prop, unoControl, "Time", field, 0)
-
- @classmethod
- def attachNumericControl(self, data, prop, unoControl, field):
- return self.__attachTextControl(
- data, prop, unoControl, "Value", field, float(0))
-
- @classmethod
- def attachCheckBox(
- self, data, prop, checkBox, field):
- uda = UnoDataAware(data, prop, checkBox, PropertyNames.PROPERTY_STATE)
- method = getattr(uda,"updateData")
- checkBox.addItemListener(ItemListenerProcAdapter(method))
- return uda
-
- @classmethod
- def attachLabel(self, data, prop, label, field):
- return UnoDataAware(data, prop, label, PropertyNames.PROPERTY_LABEL)
-
- @classmethod
- def attachListBox(self, data, prop, listBox, field):
- uda = UnoDataAware(data, prop, listBox, "SelectedItems", True)
- method = getattr(uda,"updateData")
- listBox.addItemListener(ItemListenerProcAdapter(method))
- return uda
diff --git a/wizards/com/sun/star/wizards/ui/event/__init__.py b/wizards/com/sun/star/wizards/ui/event/__init__.py
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/wizards/com/sun/star/wizards/ui/event/__init__.py
+++ /dev/null