summaryrefslogtreecommitdiff
path: root/wizards/com/sun
diff options
context:
space:
mode:
Diffstat (limited to 'wizards/com/sun')
-rw-r--r--wizards/com/sun/star/wizards/ui/ImageList.py213
-rw-r--r--wizards/com/sun/star/wizards/ui/event/CommonListener.py17
-rw-r--r--wizards/com/sun/star/wizards/ui/event/ListModelBinder.py36
-rw-r--r--wizards/com/sun/star/wizards/web/BackgroundsDialog.py60
-rw-r--r--wizards/com/sun/star/wizards/web/IconsDialog.py33
-rw-r--r--wizards/com/sun/star/wizards/web/ImageListDialog.py5
-rw-r--r--wizards/com/sun/star/wizards/web/WWD_Events.py51
-rw-r--r--wizards/com/sun/star/wizards/web/WebConfigSet.py58
8 files changed, 306 insertions, 167 deletions
diff --git a/wizards/com/sun/star/wizards/ui/ImageList.py b/wizards/com/sun/star/wizards/ui/ImageList.py
index f21bcb777d35..a42eb01a8d96 100644
--- a/wizards/com/sun/star/wizards/ui/ImageList.py
+++ b/wizards/com/sun/star/wizards/ui/ImageList.py
@@ -16,11 +16,16 @@
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
import uno
+import traceback
+from abc import abstractmethod
from threading import RLock
from .PeerConfig import PeerConfig
+from .event.CommonListener import OMouseListenerProcAdapter
from ..common.PropertyNames import PropertyNames
from ..common.HelpIds import HelpIds
+from ..common.IRenderer import IRenderer
+from .event.ListDataListener import ListDataListener
from com.sun.star.awt import Size
@@ -36,7 +41,7 @@ def synchronized(lock):
return newFunction
return wrap
-class ImageList(object):
+class ImageList(ListDataListener):
NO_BORDER = 0
BACKGROUND_COLOR = 16777216
HIDE_PAGE = 99
@@ -54,7 +59,7 @@ class ImageList(object):
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP)
lock = RLock()
- listModel = []
+ listModel = None
btnNext = None
btnBack = None
@@ -74,11 +79,16 @@ class ImageList(object):
self.selected = -1
self.pageStart = 0
self.helpURL = 0
+ self.renderer = None
self.counterRenderer = self.SimpleCounterRenderer()
self.MOVE_SELECTION_VALS = list(range(3))
+ self.itemListenerList = None
+
+ def onMousePressed(self, event):
+ self.focus(self.getImageIndexFor(self.selected))
+
def create(self, dialog):
- print ("DEBUG !!!! ImageList create 1")
self.oUnoDialog = dialog
self.dialogModel = dialog.xDialogModel
imageTextHeight = self.imageTextLines * ImageList.LINE_HEIGHT
@@ -119,9 +129,8 @@ class ImageList(object):
0, #posx
0, #posy
self.step, True, selectionWidth))
- print ("DEBUG !!!! ImageList create 2")
xWindow = self.grbxSelectedImage
- xWindow.addMouseListener(None)
+ xWindow.addMouseListener(OMouseListenerProcAdapter(self.onMousePressed))
pNames1 = (PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_HELPURL,
PropertyNames.PROPERTY_POSITION_X,
@@ -136,7 +145,6 @@ class ImageList(object):
* self.rows + self.gap.Height, self.step, 0, False,
self.cols * (self.imageSize.Width + self.gap.Width) \
+ self.gap.Width - 2))
- print ("DEBUG !!!! ImageList create 3")
if self.showButtons:
ImageList.btnBack = dialog.insertButton(
self.name + "_btnBack", "prevPage", pNames1,
@@ -145,7 +153,6 @@ class ImageList(object):
(self.imageSize.Height + self.gap.Height) * \
self.rows + self.gap.Height + imageTextHeight + 1,
self.step, self.tabIndex + 1, True, 14), self)
- print ("DEBUG !!!! ImageList create 3.1")
ImageList.btnNext = dialog.insertButton(
self.name + "_btnNext", "nextPage", pNames1,
(14, HelpIds.getHelpIdString((self.helpURL + 1)),
@@ -154,17 +161,15 @@ class ImageList(object):
self.pos.Height + (self.imageSize.Height + self.gap.Height) \
* self.rows + self.gap.Height + imageTextHeight + 1,
self.step, self.tabIndex + 2, True, 14), self)
- print ("DEBUG !!!! ImageList create 3.2")
self.lblCounter = dialog.insertLabel(
self.name + "_lblCounter", pNames1,
- (ImageList.LINE_HEIGHT, "", self.pos.Width + 14 + 1,
+ (ImageList.LINE_HEIGHT, "", self.pos.Width + 14 + 1,int(
self.pos.Height + (self.imageSize.Height + self.gap.Height) \
* self.rows + self.gap.Height + imageTextHeight + \
- ((14 - ImageList.LINE_HEIGHT) / 2),
+ ((14 - ImageList.LINE_HEIGHT) / 2)),
self.step, 0, False, self.cols * \
(self.imageSize.Width + self.gap.Width) + \
self.gap.Width - 2 * 14 - 1))
- print ("DEBUG !!!! ImageList create 3.3")
self.lblCounter.Model.Align = 1
ImageList.btnBack.Model.Label = "<"
ImageList.btnNext.Model.Label = ">"
@@ -176,8 +181,7 @@ class ImageList(object):
self.m_aImages[r * self.cols + c] = self.createImage(dialog, r, c)
self.refreshImages()
- #COMMENTED
- #ImageList.listModel.addListDataListener(None)
+ self.listModel.addListDataListener(self)
#used for optimization
@@ -185,14 +189,18 @@ class ImageList(object):
imageName = self.name + "_image" + str(_row * self.cols + _col)
image = dialog.insertImage(
imageName, ImageList.IMAGE_PROPS,
- (ImageList.NO_BORDER, ImageList.BACKGROUND_COLOR,
- self.imageSize.Height,
- HelpIds.getHelpIdString(self.helpURL + 1),
- self.getImagePosX(_col), self.getImagePosY(_row),
- self.scaleImages, self.step, self.tabIndex,
- False, self.imageSize.Width))
+ (ImageList.NO_BORDER,
+ ImageList.BACKGROUND_COLOR,
+ self.imageSize.Height,
+ HelpIds.getHelpIdString(self.helpURL + 1),
+ self.getImagePosX(_col), self.getImagePosY(_row),
+ self.scaleImages,
+ self.step,
+ self.tabIndex,
+ False,
+ self.imageSize.Width))
#COMMENTED
- image.addMouseListener(None)
+ image.addMouseListener(OMouseListenerProcAdapter(self.mousePressed))
image.addKeyListener(None)
return image
@@ -216,8 +224,7 @@ class ImageList(object):
focusable = True
for index, item in enumerate(self.m_aImages):
- #COMMENTED
- oResources = None #self.renderer.getImageUrls(self.getObjectFor(index))
+ oResources = self.renderer.getImageUrls(self.getObjectFor(index))
if oResources is not None:
if len(oResources) == 1:
item.Model.ImageURL = oResources[0]
@@ -236,12 +243,12 @@ class ImageList(object):
def refreshCounterText(self):
self.lblCounter.Model.Label = self.counterRenderer.render(
self.Counter (self.pageStart + 1, self.pageEnd,
- len(ImageList.listModel)))
+ self.listModel.getSize()))
def pageEnd(self):
i = self.pageStart + self.cols * self.rows
- if i > ImageList.listModel.getSize() - 1:
- return ImageList.listModel.getSize()
+ if i > self.listModel.getSize() - 1:
+ return self.listModel.getSize()
else:
return i
@@ -261,22 +268,21 @@ class ImageList(object):
'''
def moveSelection(self, image):
- print ("DEBUG !!! moveSelection - image: ", image)
self.grbxSelectedImage.Visible = False
- row = image / self.cols
+ row = int(image / self.cols)
if self.rowSelect:
col = 0
else:
col = image - (row * self.cols)
self.MOVE_SELECTION_VALS[0] = \
- (self.getImagePosX(col) - self.selectionGap.Width)
+ int(self.getImagePosX(col) - self.selectionGap.Width)
self.MOVE_SELECTION_VALS[1] = \
- (self.getImagePosY(row) - self.selectionGap.Height)
+ int(self.getImagePosY(row) - self.selectionGap.Height)
uno.invoke(self.grbxSelectedImage.Model, "setPropertyValues",
((ImageList.MOVE_SELECTION),
(tuple(self.MOVE_SELECTION_VALS))))
- if (self.grbxSelectedImage.Model.Step == self.step):
+ if (self.dialogModel.Step == self.step):
self.grbxSelectedImage.Visible = True
#now focus...
@@ -293,10 +299,10 @@ class ImageList(object):
def getObjectFor(self, i):
ii = self.getIndexFor(i)
- if ImageList.listModel.getSize() <= ii:
+ if self.listModel.getSize() <= ii:
return None
else:
- return ImageList.listModel.getElementAt(ii)
+ return self.listModel.getElementAt(ii)
'''
@param i
@@ -307,18 +313,16 @@ class ImageList(object):
return self.pageStart + i
def getImageIndexFor(self, i):
- print ("DEBUG !!! getImageIndexFor - i: ", i)
return i - self.pageStart
def intervalAdded(self, event):
- print ("DEBUG !!!! intervalAdded - event: ", event)
if event.getIndex0() <= self.selected:
if event.getIndex1() <= self.selected:
self.selected += event.getIndex1() - event.getIndex0() + 1
if event.getIndex0() < self.pageStart or \
- event.getIndex1() < (self.pageStart + getRows() + getCols()):
- refreshImages()
+ event.getIndex1() < (self.pageStart + self.rows + self.cols):
+ self.refreshImages()
'''
Registers ItemListener to receive events.
@@ -328,8 +332,7 @@ class ImageList(object):
@synchronized(lock)
def addItemListener(self, listener):
if self.itemListenerList is None:
- self.itemListenerList = java.util.ArrayList.ArrayList()
-
+ self.itemListenerList = []
self.itemListenerList.append(listener)
'''
@@ -348,49 +351,57 @@ class ImageList(object):
'''
def fireItemSelected(self):
- with ImageList.lock:
- if self.itemListenerList is None:
- return
-
- auxlist = self.itemListenerList.clone()
-
+ if self.itemListenerList is None:
+ return
+ auxlist = list(self.itemListenerList)
for i in auxlist:
i.itemStateChanged(None)
+ def getSelected(self):
+ return self.selected
+
def setSelected(self, _object):
- print ("DEBUG !!!! setSelected - _object: ", _object)
- if not isinstance(_object, int):
- _object = -1
- if _object is not None:
- for index, item in enumerate(ImageList.listModel):
- if item == _object:
- _object = index
- return
-
- if self.rowSelect and (_object >= 0):
- _object = (_object / self.cols) * self.cols
-
- if self.selected == _object:
+ if (isinstance (_object, int)):
+ self.setSelected1(_object)
+ elif (_object is None or _object is ""):
+ self.setSelected1(-1)
+ else:
+ i = 0
+ while (i < self.listModel.getSize()):
+ item = self.listModel.getElementAt(i)
+ if item == _object:
+ self.setSelected1(i)
+ return
+ i += 1
+
+ def setSelected1(self, index):
+ if self.rowSelect and (index >= 0):
+ index = int(index / self.cols) * self.cols
+
+ if self.selected == index:
return
- self.selected = _object
+ self.selected = index
self.refreshImageText()
self.refreshSelection()
- #COMMENTED
- #self.fireItemSelected()
+ self.fireItemSelected()
+
def refreshImageText(self):
if self.selected >= 0:
- #COMMENTED
- item = None #ImageList.listModel.getElementAt(self.selected)
+ try:
+ item = self.listModel.getElementAt(self.selected)
+ except IndexError:
+ item = None
+ traceback.print_exc()
else:
item = None
self.lblImageText.Model.Label = " " + self.renderer.render(item)
def nextPage(self):
- if self.pageStart < listModel().getSize() - self.rows * self.cols:
- setPageStart(self.pageStart + self.rows * self.cols)
+ if self.pageStart < self.listModel.getSize() - self.rows * self.cols:
+ self.setPageStart(self.pageStart + self.rows * self.cols)
def prevPage(self):
if self.pageStart == 0:
@@ -400,12 +411,19 @@ class ImageList(object):
if i < 0:
i = 0
- setPageStart(i)
+ self.setPageStart(i)
+
+ def setPageStart(self, i):
+ if (i == self.pageStart):
+ return
+ self.pageStart = i
+ self.enableButtons()
+ self.refreshImages()
def enableButtons(self):
self.enable(
ImageList.btnNext,
- bool(self.pageStart + self.rows * self.cols < len(ImageList.listModel)))
+ bool(self.pageStart + self.rows * self.cols < self.listModel.getSize()))
self.enable(ImageList.btnBack, bool(self.pageStart > 0))
def enable(self, control, enable):
@@ -417,19 +435,28 @@ class ImageList(object):
def getImageFromEvent(self, event):
image = (event).Source
controlName = image.Model.Name
- return Integer.valueOf(controlName.substring(6 + self.name.length()))
+ return int(controlName[6 + len(self.name):])
def mousePressed(self, event):
- image = getImageFromEvent(event)
- index = getIndexFor(image)
- if index < ImageList.listModel.getSize():
- focus(image)
- setSelected(index)
+ image = self.getImageFromEvent(event)
+ index = self.getIndexFor(image)
+ if index < self.listModel.getSize():
+ self.focus(image)
+ self.setSelected(index)
def getSelectedObjects(self):
- return[listModel().getElementAt(self.selected)]
+ return[self.listModel.getElementAt(self.selected)]
+
+ class IImageRenderer(IRenderer):
- class SimpleCounterRenderer:
+ # @param listItem
+ # @return two resource ids for an image referenced in the imaglist resourcefile of the
+ # wizards project; The second one of them is designed to be used for High Contrast Mode.
+ @abstractmethod
+ def getImageUrls(self, listItem):
+ pass
+
+ class SimpleCounterRenderer(IRenderer):
def render(self, counter):
return \
@@ -444,42 +471,44 @@ class ImageList(object):
def getSelectedObject(self):
if self.selected >= 0:
- return listModel().getElementAt(self.selected)
+ try:
+ return self.listModel.getElementAt(self.selected)
+ except IndexError:
+ traceback.print_exc()
return None
def showSelected(self):
oldPageStart = self.pageStart
if self.selected != -1:
self.pageStart = \
- (self.selected / len(self.m_aImages)) * len(self.m_aImages)
+ int((self.selected / len(self.m_aImages)) * len(self.m_aImages))
if oldPageStart != self.pageStart:
- #COMMENTED
- #self.enableButtons()
+ self.enableButtons()
self.refreshImages()
def keyPressed(self, ke):
- image = getImageFromEvent(ke)
- r = image / getCols()
- c = image - (r * getCols())
- d = getKeyMove(ke, r, c)
+ image = self.getImageFromEvent(ke)
+ r = image / self.cols
+ c = image - (r * self.cols)
+ d = self.getKeyMove(ke, r, c)
newImage = image + d
if newImage == image:
return
- if isFocusable(newImage):
- changeFocus(image, newImage)
+ if self.isFocusable(newImage):
+ self.changeFocus(image, newImage)
def isFocusable(self, image):
return (image >= 0) and \
- (getIndexFor(image) < ImageList.listModel.getSize())
+ (self.getIndexFor(image) < self.listModel.getSize())
def changeFocus(self, oldFocusImage, newFocusImage):
- focus(newFocusImage)
- defocus(oldFocusImage)
+ self.focus(newFocusImage)
+ self.defocus(oldFocusImage)
def select(self, ke):
- setSelected(getIndexFor(getImageFromEvent(ke)))
+ self.setSelected(self.getIndexFor(self.getImageFromEvent(ke)))
def focus(self, image):
self.m_aImages[image].Model.Tabstop = True
@@ -495,13 +524,13 @@ class ImageList(object):
'''
def display(self, i):
- isAux = (getCols() * getRows())
- ps = (ImageList.listModel.getSize() / isAux) * isAux
- setPageStart(ps)
+ isAux = (self.cols * self.rows)
+ ps = (self.listModel.getSize() / isAux) * isAux
+ self.setPageStart(ps)
def setenabled(self, b):
i = 0
- while i < self.m_aImages.length:
+ while i < len(self.m_aImages):
UnoDialog2.setEnabled(self.m_aImages[i], b)
i += 1
UnoDialog2.setEnabled(self.grbxSelectedImage, b)
diff --git a/wizards/com/sun/star/wizards/ui/event/CommonListener.py b/wizards/com/sun/star/wizards/ui/event/CommonListener.py
index 4883a1617706..9c61db8b4924 100644
--- a/wizards/com/sun/star/wizards/ui/event/CommonListener.py
+++ b/wizards/com/sun/star/wizards/ui/event/CommonListener.py
@@ -93,3 +93,20 @@ class KeyListenerProcAdapter( unohelper.Base, XKeyListener ):
def keyPressed(self, KeyEvent):
if callable( self.oProcToCall ):
self.oProcToCall(KeyEvent)
+
+ def disposing(self, Event):
+ # TODO: Implement ?
+ pass
+
+from com.sun.star.awt import XMouseListener
+class OMouseListenerProcAdapter( unohelper.Base, XMouseListener ):
+ def __init__(self, oProcToCall):
+ self.oProcToCall = oProcToCall
+
+ def mousePressed(self, MouseEvent):
+ if callable( self.oProcToCall ):
+ self.oProcToCall(MouseEvent)
+
+ def disposing(self, Event):
+ # TODO: Implement ?
+ pass
diff --git a/wizards/com/sun/star/wizards/ui/event/ListModelBinder.py b/wizards/com/sun/star/wizards/ui/event/ListModelBinder.py
index 5cbe5ae52a32..863a696b97fb 100644
--- a/wizards/com/sun/star/wizards/ui/event/ListModelBinder.py
+++ b/wizards/com/sun/star/wizards/ui/event/ListModelBinder.py
@@ -16,20 +16,25 @@
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
-class ListModelBinder(object):
+from abc import abstractmethod
+
+from .ListDataListener import ListDataListener
+
+class ListModelBinder(ListDataListener):
def __init__(self, unoListBox, listModel_):
self.unoList = unoListBox
self.unoListModel = unoListBox.Model
- #COMMENTED
- #self.setListModel(listModel_)
+ self.listModel = None
+ self.setListModel(listModel_)
+ self.renderer = self.Renderer()
def setListModel(self, newListModel):
if self.listModel is not None:
self.listModel.removeListDataListener(self)
self.listModel = newListModel
- self.listModel.addListDataListener(this)
+ self.listModel.addListDataListener(self)
def contentsChanged(self, lde):
selected = self.getSelectedItems()
@@ -50,9 +55,9 @@ class ListModelBinder(object):
self.unoList.addItem(self.getItemString(i), i)
def getItemString(self, i):
- return self.getItemString(self.listModel.getElementAt(i))
+ return self.getItemString1(self.listModel.getElementAt(i))
- def getItemString(self, item):
+ def getItemString1(self, item):
return self.renderer.render(item)
def getSelectedItems(self):
@@ -62,11 +67,24 @@ class ListModelBinder(object):
self.unoListModel.SelectedItems = selected;
def intervalAdded(self, lde):
- for i in xrange(lde.Index0, lde.Index1):
+ i = lde.getIndex0()
+ while (i <= lde.getIndex1()):
self.insert(i)
+ i += 1
def intervalRemoved(self, lde):
- self.remove(lde.Index0, lde.Index1)
+ self.remove(lde.getIndex0(), lde.getIndex1())
+
+ class Renderer:
+
+ @abstractmethod
+ def render(self, item):
+ if (item is None):
+ return ""
+ elif (isinstance(item, int)):
+ return str(item)
+ else:
+ return item.toString()
@classmethod
def fillList(self, xlist, items, renderer):
@@ -76,7 +94,7 @@ class ListModelBinder(object):
if renderer is not None:
aux = renderer.render(index)
else:
- aux = item.cp_Name
+ aux = item.toString()
xlist.addItem(aux, index)
@classmethod
diff --git a/wizards/com/sun/star/wizards/web/BackgroundsDialog.py b/wizards/com/sun/star/wizards/web/BackgroundsDialog.py
index 936aa167a6ee..67fa94362510 100644
--- a/wizards/com/sun/star/wizards/web/BackgroundsDialog.py
+++ b/wizards/com/sun/star/wizards/web/BackgroundsDialog.py
@@ -24,6 +24,8 @@ from .WebWizardConst import *
from ..common.SystemDialog import SystemDialog
from ..common.FileAccess import FileAccess
from ..common.Configuration import Configuration
+from ..common.ListModel import ListModel
+from ..ui.ImageList import ImageList
from com.sun.star.awt import Size
@@ -47,8 +49,9 @@ class BackgroundsDialog(ImageListDialog):
self.fileAccess = FileAccess(xmsf)
#COMMENTED
#self.il.setListModel(Model(set_))
+ self.il.listModel = self.Model(set_, self)
self.il.imageSize = Size (40, 40)
- #self.il.setRenderer(BGRenderer (0))
+ self.il.renderer = self.BGRenderer(0, self)
self.build()
'''
@@ -106,26 +109,22 @@ class BackgroundsDialog(ImageListDialog):
@author rpiterman
'''
- class BGRenderer(object):
+ class BGRenderer(ImageList.IImageRenderer):
+ cut = 0
- def __init__(self, cut_):
- ImageListDialog.ImageListDialog_body()
+ def __init__(self, cut_, parent):
self.cut = cut_
+ self.parent = parent
def getImageUrls(self, listItem):
sRetUrls = []
if (listItem is not None):
sRetUrls.append(listItem)
return sRetUrls
-
return None
- def render(self, _object):
- if _object is None:
- return ""
- else:
- return FileAccess.getPathFilename(
- self.fileAccess.getPath(_object, None))
+ def render(self, obj):
+ return "" if (obj is None) else FileAccess.getFilename(self.parent.fileAccess.getPath(obj, None))
'''
This is a list model for the image list of the
@@ -138,7 +137,11 @@ class BackgroundsDialog(ImageListDialog):
@author rpiterman
'''
- class Model(object):
+ class Model(ListModel):
+
+ parent = None
+ listModel = []
+
'''
constructor. </br>
see class description for a description of
@@ -146,17 +149,18 @@ class BackgroundsDialog(ImageListDialog):
@param model the configuration set of the background images.
'''
- def __init__(self, model):
+ def __init__(self, model, parent):
+ self.parent = parent
try:
i = 0
while i < model.getSize():
image = model.getElementAt(i)
- path = self.sd.xStringSubstitution.substituteVariables(
+ path = parent.sd.xStringSubstitution.substituteVariables(
image.cp_Href, False)
- if self.fileAccess.exists(path, False):
- addDir(path)
+ if parent.fileAccess.exists(path, False):
+ self.addDir(path)
else:
- remove(model.getKey(image))
+ self.remove(model.getKey(image))
i += 1
except Exception:
@@ -173,7 +177,7 @@ class BackgroundsDialog(ImageListDialog):
def remove(self, imageName):
try:
conf = Configuration.getConfigurationRoot(
- self.xMSF, WebWizardConst.CONFIG_PATH + "/BackgroundImages",
+ self.parent.xMSF, CONFIG_PATH + "/BackgroundImages",
True)
Configuration.removeNode(conf, imageName)
except Exception:
@@ -187,10 +191,10 @@ class BackgroundsDialog(ImageListDialog):
'''
def addDir(self, url):
- if self.fileAccess.isDirectory(url):
- self.add(self.fileAccess.listFiles(url, False))
+ if self.parent.fileAccess.isDirectory(url):
+ self.add(self.parent.fileAccess.listFiles(url, False))
else:
- self.add(url)
+ self.add1(url)
'''
adds the given filenames (urls) to
@@ -212,7 +216,13 @@ class BackgroundsDialog(ImageListDialog):
'''
def add1(self, filename):
- lcase = filename.toLowerCase()
- if lcase.endsWith("jpg") or lcase.endsWith("jpeg") or \
- lcase.endsWith("gif"):
- Model.this.addElement(filename)
+ lcase = filename.lower()
+ if lcase.endswith("jpg") or lcase.endswith("jpeg") or \
+ lcase.endswith("gif"):
+ self.listModel.append(filename)
+
+ def getSize(self):
+ return len(self.listModel)
+
+ def getElementAt(self, arg0):
+ return self.listModel[arg0]
diff --git a/wizards/com/sun/star/wizards/web/IconsDialog.py b/wizards/com/sun/star/wizards/web/IconsDialog.py
index 09191e341015..31f834bb8dc1 100644
--- a/wizards/com/sun/star/wizards/web/IconsDialog.py
+++ b/wizards/com/sun/star/wizards/web/IconsDialog.py
@@ -19,6 +19,8 @@
from .ImageListDialog import ImageListDialog
from .WWHID import HID_IS
from ..common.FileAccess import FileAccess
+from ..common.ListModel import ListModel
+from ..ui.ImageList import ImageList
from com.sun.star.awt import Size
@@ -31,7 +33,7 @@ It also implements the ImageList.ImageRenderer interface, to handle
its own objects.
'''
-class IconsDialog(ImageListDialog):
+class IconsDialog(ImageListDialog, ImageList.IImageRenderer, ListModel):
def __init__(self, xmsf, set_, resources):
super(IconsDialog, self).__init__(xmsf, HID_IS,
@@ -48,7 +50,7 @@ class IconsDialog(ImageListDialog):
self.icons = \
["firs", "prev", "next", "last", "nav", "text", "up", "down"]
self.set = set_
- self.objects = (self.set.getSize() * len(self.icons),)
+ self.objects = range(self.set.getSize() * len(self.icons))
self.il.listModel = self
self.il.renderer = self
@@ -66,16 +68,24 @@ class IconsDialog(ImageListDialog):
if self.getSelected() is None:
return None
else:
- return self.set.getKey((self.getSelected()) / len(self.icons))
+ selected = self.getSelected()
+ value = int(selected / len(self.icons))
+ return "iconset" + str(value)
+ #return self.set.getKey(value)
def setIconset(self, iconset):
- #COMMENTED
- icon = 0 #self.set.getIndexOf(self.set.getElement(iconset)) * len(self.icons)
+ icon = self.set.getIndexOf(self.set.getElement(iconset)) * len(self.icons)
aux = None
if icon >=0:
aux = self.objects[icon]
self.setSelected(aux)
+ def addListDataListener(self, listener):
+ pass
+
+ def removeListDataListener(self, listener):
+ pass
+
def getSize(self):
return self.set.getSize() * len(self.icons)
@@ -83,10 +93,10 @@ class IconsDialog(ImageListDialog):
return self.objects[arg0]
def getImageUrls(self, listItem):
- i = (listItem).intValue()
- iset = getIconsetNum(i)
- icon = getIconNum(i)
- sRetUrls = range(2)
+ i = listItem
+ iset = self.getIconsetNum(i)
+ icon = self.getIconNum(i)
+ sRetUrls = list(range(2))
sRetUrls[0] = self.htmlexpDirectory + "/htmlexpo/" \
+ self.getIconsetPref(iset) + self.icons[icon] + self.getIconsetPostfix(iset)
sRetUrls[1] = sRetUrls[0]
@@ -95,12 +105,13 @@ class IconsDialog(ImageListDialog):
def render(self, object):
if object is None:
return ""
- i = (object).intValue()
+
+ i = object
iset = self.getIconsetNum(i)
return self.getIconset1(iset).cp_Name
def getIconsetNum(self, i):
- return i / self.icons.length
+ return int(i / len(self.icons))
def getIconNum(self, i):
return i % len(self.icons)
diff --git a/wizards/com/sun/star/wizards/web/ImageListDialog.py b/wizards/com/sun/star/wizards/web/ImageListDialog.py
index 746f71cbec09..156ea150f74f 100644
--- a/wizards/com/sun/star/wizards/web/ImageListDialog.py
+++ b/wizards/com/sun/star/wizards/web/ImageListDialog.py
@@ -21,6 +21,7 @@ from ..ui.UnoDialog2 import UnoDialog2
from ..ui.ImageList import ImageList
from ..common.HelpIds import HelpIds
from ..common.PropertyNames import PropertyNames
+from ..common.IRenderer import IRenderer
from com.sun.star.awt import FontDescriptor
from com.sun.star.awt.PushButtonType import OK, CANCEL, HELP, STANDARD
@@ -93,7 +94,6 @@ class ImageListDialog(UnoDialog2):
'''
def build(self):
- print ("DEBUG !!!! ImageListDialog build 1")
#set dialog properties...
ilWidth = (self.il.imageSize.Width + self.il.gap.Width) \
* self.il.cols + self.il.gap.Width
@@ -169,7 +169,6 @@ class ImageListDialog(UnoDialog2):
self.il.helpURL = self.hid + 5
self.il.tabIndex = 1
self.il.create(self)
- print ("DEBUG !!!! ImageListDialog build 2")
self.lblTitle = self.insertLabel("lblTitle",
("FontDescriptor",
PropertyNames.PROPERTY_HEIGHT,
@@ -213,7 +212,7 @@ class ImageListDialog(UnoDialog2):
"%TOTAL" with the respective values.
@author rpiterman
'''
- class ARenderer(object):
+ class ARenderer(IRenderer):
'''
@param aTempalte a template for this renderer.
diff --git a/wizards/com/sun/star/wizards/web/WWD_Events.py b/wizards/com/sun/star/wizards/web/WWD_Events.py
index b227912578a3..b72032fb301f 100644
--- a/wizards/com/sun/star/wizards/web/WWD_Events.py
+++ b/wizards/com/sun/star/wizards/web/WWD_Events.py
@@ -51,10 +51,6 @@ session methods.
class WWD_Events(WWD_Startup):
- iconsDialog = None
- bgDialog = None
- docPreview = None
-
'''
He - my constructor !
I add a window listener, which, when
@@ -70,6 +66,9 @@ class WWD_Events(WWD_Startup):
self.exitOnCreate = True
self.time = 0
self.count = 0
+ self.bgDialog = None
+ self.iconsDialog = None
+ self.docPreview = None
@classmethod
def main(self, args):
@@ -341,18 +340,18 @@ class WWD_Events(WWD_Startup):
def chooseBackground(self):
try:
self.setEnabled(self.btnBackgrounds, False)
- if WWD_Events.bgDialog is None:
- WWD_Events.bgDialog = BackgroundsDialog(
- self.xMSF, WWD_Startup.settings.cp_BackgroundImages,
+ if self.bgDialog is None:
+ self.bgDialog = BackgroundsDialog(
+ self.xMSF, self.settings.cp_BackgroundImages,
self.resources)
- WWD_Events.bgDialog.createWindowPeer(self.xUnoDialog.Peer)
+ self.bgDialog.createWindowPeer(self.xUnoDialog.Peer)
- WWD_Events.bgDialog.setSelected(
- WWD_Startup.settings.cp_DefaultSession.cp_Design.cp_BackgroundImage)
- i = WWD_Events.bgDialog.executeDialogFromParent(self)
+ self.bgDialog.setSelected(
+ self.settings.cp_DefaultSession.cp_Design.cp_BackgroundImage)
+ i = self.bgDialog.executeDialogFromParent(self)
if i == 1:
#ok
- self.setBackground(WWD_Events.bgDialog.getSelected())
+ self.setBackground(self.bgDialog.getSelected())
except Exception:
traceback.print_exc()
finally:
@@ -366,7 +365,7 @@ class WWD_Events(WWD_Startup):
if background is None:
background = ""
- WWD_Startup.settings.cp_DefaultSession.cp_Design.cp_BackgroundImage \
+ self.settings.cp_DefaultSession.cp_Design.cp_BackgroundImage \
= background
self.refreshStylePreview()
@@ -377,18 +376,18 @@ class WWD_Events(WWD_Startup):
def chooseIconset(self):
try:
self.setEnabled(self.btnIconSets, False)
- if WWD_Events.iconsDialog is None:
- WWD_Events.iconsDialog = IconsDialog(
- self.xMSF, WWD_Startup.settings.cp_IconSets,
+ if self.iconsDialog is None:
+ self.iconsDialog = IconsDialog(
+ self.xMSF, self.settings.cp_IconSets,
self.resources)
- WWD_Events.iconsDialog.createWindowPeer(self.xUnoDialog.Peer)
+ self.iconsDialog.createWindowPeer(self.xUnoDialog.Peer)
- WWD_Events.iconsDialog.setIconset(
- WWD_Startup.settings.cp_DefaultSession.cp_Design.cp_IconSet)
- i = WWD_Events.iconsDialog.executeDialogFromParent(self)
+ self.iconsDialog.setIconset(
+ self.settings.cp_DefaultSession.cp_Design.cp_IconSet)
+ i = self.iconsDialog.executeDialogFromParent(self)
if i == 1:
#ok
- self.setIconset(WWD_Events.iconsDialog.getIconset())
+ self.setIconset(self.iconsDialog.getIconset())
except Exception:
traceback.print_exc()
finally:
@@ -399,7 +398,7 @@ class WWD_Events(WWD_Startup):
'''
def setIconset(self, icon):
- WWD_Startup.settings.cp_DefaultSession.cp_Design.cp_IconSet = icon
+ self.settings.cp_DefaultSession.cp_Design.cp_IconSet = icon
self.updateIconsetText()
'''
@@ -892,11 +891,11 @@ class WWD_Events(WWD_Startup):
self.dpStylePreview.dispose()
self.stylePreview.cleanup()
- if WWD_Events.bgDialog is not None:
- WWD_Events.bgDialog.xUnoDialog.dispose()
+ if self.bgDialog is not None:
+ self.bgDialog.xUnoDialog.dispose()
- if WWD_Events.iconsDialog is not None:
- WWD_Events.iconsDialog.xUnoDialog.dispose()
+ if self.iconsDialog is not None:
+ self.iconsDialog.xUnoDialog.dispose()
if self.ftpDialog is not None:
self.ftpDialog.xUnoDialog.dispose()
diff --git a/wizards/com/sun/star/wizards/web/WebConfigSet.py b/wizards/com/sun/star/wizards/web/WebConfigSet.py
index 88b49f227666..bdf9bdb5a1ce 100644
--- a/wizards/com/sun/star/wizards/web/WebConfigSet.py
+++ b/wizards/com/sun/star/wizards/web/WebConfigSet.py
@@ -19,6 +19,9 @@ import traceback
from ..common.ConfigGroup import ConfigGroup
from ..common.Configuration import Configuration
from ..common.XMLProvider import XMLProvider
+from ..ui.event.EventListenerList import EventListenerList
+from ..ui.event.ListDataEvent import ListDataEvent
+from ..ui.event.ListDataListener import ListDataListener
class WebConfigSet(ConfigGroup):
'''
@@ -36,6 +39,7 @@ class WebConfigSet(ConfigGroup):
self.childrenMap = {}
self.childrenList = []
self.noNulls = False
+ self.listenerList = None
def add(self, name, o):
print ("DEBUG !!! WebConfigSet.add -- name: ", name)
@@ -49,6 +53,7 @@ class WebConfigSet(ConfigGroup):
i = int(name)
print ("DEBUG !!! WebConfigSet.add -- name IS an integer.")
self.childrenList.insert(i, o)
+ self.fireListDataListenerIntervalAdded(i, i);
except Exception:
print ("DEBUG !!! WebConfigSet.add -- name IS NOT an integer.")
try:
@@ -66,6 +71,7 @@ class WebConfigSet(ConfigGroup):
self.childrenList.insert(i, o)
if oldSize > i:
oldSize = i
+ self.fireListDataListenerIntervalAdded(oldSize, i);
except Exception:
if (oldO is not None):
print ("DEBUG !!! WebConfigSet.add -- No cp_Index attribute, but element already present, so replace it.")
@@ -74,6 +80,7 @@ class WebConfigSet(ConfigGroup):
else:
print ("DEBUG !!! WebConfigSet.add -- No cp_Index attribute, so just append it.")
self.childrenList.append(o)
+ self.fireListDataListenerIntervalAdded(self.getSize() - 1, self.getSize() - 1);
def writeConfiguration(self, configView, param):
@@ -126,7 +133,7 @@ class WebConfigSet(ConfigGroup):
self.childrenMap.remove(key)
i = self.childrenList.indexOf(obj)
self.childrenList.remove(obj)
- #fireListDataListenerIntervalRemoved(i, i)
+ self.fireListDataListenerIntervalRemoved(i, i)
def remove(self, i):
o = getElementAt(i)
@@ -136,6 +143,9 @@ class WebConfigSet(ConfigGroup):
self.childrenMap.clear()
del self.childrenList[:]
+ def update(i):
+ self.fireListDataListenerContentsChanged(i, i)
+
def createDOM(self, parent):
items = self.childrenList
i = 0
@@ -207,3 +217,49 @@ class WebConfigSet(ConfigGroup):
def sort(self, comparator):
self.childrenList.sort(comparator)
+
+
+ # Registers ListDataListener to receive events.
+ # @param listener The listener to register.
+ def addListDataListener(self, listener):
+ if (self.listenerList is None):
+ self.listenerList = EventListenerList()
+ self.listenerList.add(listener)
+
+ # Removes ListDataListener from the list of listeners.
+ # @param listener The listener to remove.
+ def removeListDataListener(self, listener):
+ self.listenerList.remove(listener)
+
+ # Notifies all registered listeners about the event.
+ #
+ # @param event The event to be fired
+ def fireListDataListenerIntervalAdded(self, i0, i1):
+ event = ListDataEvent(self, ListDataEvent.INTERVAL_ADDED, i0, i1)
+ if (self.listenerList is None):
+ return
+ for listener in self.listenerList.getListenerList():
+ if isinstance(listener, ListDataListener):
+ listener.intervalAdded(event)
+
+ # Notifies all registered listeners about the event.
+ #
+ # @param event The event to be fired
+ def fireListDataListenerIntervalRemoved(self, i0, i1):
+ event = ListDataEvent(self, ListDataEvent.INTERVAL_REMOVED, i0, i1)
+ if (self.listenerList is None):
+ return
+ for listener in self.listenerList.getListenerList():
+ if isinstance(listener, ListDataListener):
+ listener.intervalRemoved(event)
+
+ # Notifies all registered listeners about the event.
+ #
+ # @param event The event to be fired
+ def fireListDataListenerContentsChanged(self, i0, i1):
+ event = ListDataEvent(self, ListDataEvent.CONTENTS_CHANGED, i0, i1)
+ if (self.listenerList is None):
+ return
+ for listener in self.listenerList.getListenerList():
+ if isinstance(listener, ListDataListener):
+ listener.contentsChanged(event)