diff options
author | Xisco Fauli <anistenis@gmail.com> | 2011-07-26 19:36:03 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2011-08-18 02:57:43 +0200 |
commit | ba5f79d6f230d06ac3ff87a43579c4ef14992ec7 (patch) | |
tree | ad790329e16b571949ae8f587971c362850a1deb /wizards | |
parent | Add checkbox listener (diff) | |
download | core-ba5f79d6f230d06ac3ff87a43579c4ef14992ec7.tar.gz core-ba5f79d6f230d06ac3ff87a43579c4ef14992ec7.zip |
Add Textfield listeners and fix a bug found in the java wizard
BUG: The time was showed wrongly
Diffstat (limited to 'wizards')
5 files changed, 109 insertions, 97 deletions
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py b/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py index e810c6c47970..3d6c0cf2c0e9 100644 --- a/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py +++ b/wizards/com/sun/star/wizards/agenda/AgendaTemplate.py @@ -23,16 +23,18 @@ def synchronized(lock): ''' The classes here implement the whole document-functionality of the agenda wizard: -the live-preview and the final "creation" of the document, when the user clicks "finish". <br/> +the live-preview and the final "creation" of the document, +when the user clicks "finish". <br/> <br/> <h2>Some terminology:<h2/> items are names or headings. we don't make any distinction. <br/> -The Agenda Template is used as general "controller" of the whole document, whereas the -two child-classes ItemsTable and TopicsTable control the item tables (note plural!) and the -topics table (note singular). -<br/> <br/> +The Agenda Template is used as general "controller" +of the whole document, whereas the two child-classes ItemsTable +and TopicsTable control the item tables (note plural!) and the +topics table (note singular).<br/> +<br/> Other small classes are used to abstract the handling of cells and text and we try to use them as components. <br/><br/> @@ -42,7 +44,8 @@ To keep the template flexible the following decisions were made:<br/> 1. Item tables.<br/> 1.a. there might be arbitrary number of Item tables.<br/> 1.b. Item tables design (bordewr, background) is arbitrary.<br/> -1.c. Items text styles are individual, and use stylelist styles with predefined names.<br/> +1.c. Items text styles are individual, +and use stylelist styles with predefined names.<br/> As result the following limitations:<br/> Pairs of Name->value for each item.<br/> Tables contain *only* those pairs.<br/> @@ -75,6 +78,7 @@ class AgendaTemplate(TextDocument): template = None agenda = None lock = RLock() + initDictionary = False '''constructor. The document is *not* loaded here. only some formal members are set. @@ -88,6 +92,10 @@ class AgendaTemplate(TextDocument): "WIZARD_LIVE_PREVIEW") AgendaTemplate.agenda = agenda_ self.resources = resources_ + + if not AgendaTemplate.initDictionary: + self.initializeDictionary() + if AgendaTemplate.itemsCache is None: self.initItemsCache() @@ -166,6 +174,20 @@ class AgendaTemplate(TextDocument): def setTemplateTitle(self, newTitle): self.m_xDocProps.Title = newTitle + def initializeDictionary(self): + AgendaTemplate.isShowItemDict = \ + {FILLIN_MEETING_TYPE:AgendaTemplate.agenda.cp_ShowMeetingType, + FILLIN_READ:AgendaTemplate.agenda.cp_ShowRead, + FILLIN_BRING:AgendaTemplate.agenda.cp_ShowBring, + FILLIN_NOTES:AgendaTemplate.agenda.cp_ShowNotes, + FILLIN_FACILITATOR:AgendaTemplate.agenda.cp_ShowFacilitator, + FILLIN_TIMEKEEPER:AgendaTemplate.agenda.cp_ShowTimekeeper, + FILLIN_NOTETAKER:AgendaTemplate.agenda.cp_ShowNotetaker, + FILLIN_PARTICIPANTS:AgendaTemplate.agenda.cp_ShowAttendees, + FILLIN_CALLED_BY:AgendaTemplate.agenda.cp_ShowCalledBy, + FILLIN_OBSERVERS:AgendaTemplate.agenda.cp_ShowObservers, + FILLIN_RESOURCE_PERSONS:AgendaTemplate.agenda.cp_ShowResourcePersons} + '''checks the data model if the item corresponding to the given string should be shown @param itemName a string representing an Item (name or heading). @@ -174,29 +196,9 @@ class AgendaTemplate(TextDocument): @classmethod def isShowItem(self, itemName): - if itemName == FILLIN_MEETING_TYPE: - return AgendaTemplate.agenda.cp_ShowMeetingType - elif itemName == FILLIN_READ: - return AgendaTemplate.agenda.cp_ShowRead - elif itemName == FILLIN_BRING: - return AgendaTemplate.agenda.cp_ShowBring - elif itemName == FILLIN_NOTES: - return AgendaTemplate.agenda.cp_ShowNotes - elif itemName == FILLIN_FACILITATOR: - return AgendaTemplate.agenda.cp_ShowFacilitator - elif itemName == FILLIN_TIMEKEEPER: - return AgendaTemplate.agenda.cp_ShowTimekeeper - elif itemName == FILLIN_NOTETAKER: - return AgendaTemplate.agenda.cp_ShowNotetaker - elif itemName == FILLIN_PARTICIPANTS: - return AgendaTemplate.agenda.cp_ShowAttendees - elif itemName == FILLIN_CALLED_BY: - return AgendaTemplate.agenda.cp_ShowCalledBy - elif itemName == FILLIN_OBSERVERS: - return AgendaTemplate.agenda.cp_ShowObservers - elif itemName == FILLIN_RESOURCE_PERSONS: - return AgendaTemplate.agenda.cp_ShowResourcePersons - else: + try: + return AgendaTemplate.isShowItemDict[itemName] + except KeyError: raise ValueError("No such item") '''itemsCache is a Map containing all agenda item. These are object which @@ -292,9 +294,9 @@ class AgendaTemplate(TextDocument): and create the date and time formatters. ''' dateUtils = Helper.DateUtils(self.xMSF, AgendaTemplate.document) - self.formatter = dateUtils.formatter - self.dateFormat = dateUtils.getFormat(DATE_SYSTEM_LONG) - self.timeFormat = dateUtils.getFormat(TIME_HHMM) + AgendaTemplate.formatter = dateUtils.formatter + AgendaTemplate.dateFormat = dateUtils.getFormat(DATE_SYSTEM_LONG) + AgendaTemplate.timeFormat = dateUtils.getFormat(TIME_HHMM) ''' get the document properties object. @@ -322,35 +324,35 @@ class AgendaTemplate(TextDocument): workwith = AgendaTemplate._allItems[i] text = workwith.String.lstrip().lower() if text == FILLIN_TITLE: - self.teTitle = PlaceholderTextElement( + AgendaTemplate.teTitle = PlaceholderTextElement( workwith, self.resources.resPlaceHolderTitle, self.resources.resPlaceHolderHint, AgendaTemplate.document) - self.trTitle = workwith + AgendaTemplate.trTitle = workwith del AgendaTemplate._allItems[i] i -= 1 elif text == FILLIN_DATE: - self.teDate = PlaceholderTextElement( + AgendaTemplate.teDate = PlaceholderTextElement( workwith, self.resources.resPlaceHolderDate, self.resources.resPlaceHolderHint, AgendaTemplate.document) - self.trDate = workwith + AgendaTemplate.trDate = workwith del AgendaTemplate._allItems[i] i -= 1 elif text == FILLIN_TIME: - self.teTime = PlaceholderTextElement( + AgendaTemplate.teTime = PlaceholderTextElement( workwith, self.resources.resPlaceHolderTime, self.resources.resPlaceHolderHint, AgendaTemplate.document) - self.trTime = workwith + AgendaTemplate.trTime = workwith del AgendaTemplate._allItems[i] i -= 1 elif text == FILLIN_LOCATION: - self.teLocation = PlaceholderTextElement( + AgendaTemplate.teLocation = PlaceholderTextElement( workwith, self.resources.resPlaceHolderLocation, self.resources.resPlaceHolderHint, AgendaTemplate.document) - self.trLocation = workwith + AgendaTemplate.trLocation = workwith del AgendaTemplate._allItems[i] i -= 1 i += 1 @@ -409,38 +411,32 @@ class AgendaTemplate(TextDocument): def getTable(self, name): return getattr(AgendaTemplate.document.TextTables, name) - ''' - implementation of DataAware.Listener, is - called when title/date/time or location are - changed. - ''' - - @synchronized(lock) - def eventPerformed(self, param): - controlName = Helper.getUnoPropertyValue( - UnoDialog2.getModel(param.Source), PropertyNames.PROPERTY_NAME) - self.redrawTitle(controlName) - + @classmethod @synchronized(lock) def redrawTitle(self, controlName): - if controlName == "txtTitle": - self.writeTitle( - self.teTitle, self.trTitle, AgendaTemplate.agenda.cp_Title) - elif controlName == "txtDate": - self.writeTitle( - self.teDate, self.trDate, - self.getDateString(AgendaTemplate.agenda.cp_Date)) - elif controlName == "txtTime": - self.writeTitle( - self.teTime, self.trTime, - self.getTimeString(AgendaTemplate.agenda.cp_Time)) - elif controlName == "cbLocation": - self.writeTitle( - self.teLocation, self.trLocation, - AgendaTemplate.agenda.cp_Location) - else: - raise IllegalArgumentException ("No such title control...") + try: + if controlName == "txtTitle": + self.writeTitle( + AgendaTemplate.teTitle, AgendaTemplate.trTitle, + AgendaTemplate.agenda.cp_Title) + elif controlName == "txtDate": + self.writeTitle( + AgendaTemplate.teDate, AgendaTemplate.trDate, + self.getDateString(AgendaTemplate.agenda.cp_Date)) + elif controlName == "txtTime": + self.writeTitle( + AgendaTemplate.teTime, AgendaTemplate.trTime, + self.getTimeString(AgendaTemplate.agenda.cp_Time)) + elif controlName == "cbLocation": + self.writeTitle( + AgendaTemplate.teLocation, AgendaTemplate.trLocation, + AgendaTemplate.agenda.cp_Location) + else: + raise IllegalArgumentException ("No such title control...") + except Exception: + traceback.print_exc() + @classmethod def writeTitle(self, te, tr, text): if text is None: te.text = "" @@ -448,6 +444,7 @@ class AgendaTemplate(TextDocument): te.text = text te.write(tr) + @classmethod def getDateString(self, d): if d is None or d == "": return "" @@ -461,15 +458,17 @@ class AgendaTemplate(TextDocument): I need a day... ''' daysDiff = (date1 - self.docNullTime) / self.__class__.DAY_IN_MILLIS + 1 - return self.formatter.convertNumberToString(self.dateFormat, daysDiff) + return AgendaTemplate.formatter.convertNumberToString( + self.dateFormat, daysDiff) + @classmethod def getTimeString(self, s): if s is None or s == "": return "" - time = int(s) - #t = (int(s) / 1000000) / 24) + (time % 1000000) / 1000) / (24 * 60) - return self.formatter.convertNumberToString(self.timeFormat, t) + t = ((time / float(1000000)) / float(24)) \ + + ((time % 1000000) / float(1000000)) / float(35) + return self.formatter.convertNumberToString(AgendaTemplate.timeFormat, t) @synchronized(lock) def finish(self, topics): @@ -1191,6 +1190,7 @@ class ParaStyled(object): def format(self, textRange): if textRange is None: textRange = textRange.Text + cursor = textRange.createTextCursorByRange(textRange) Helper.setUnoPropertyValue( cursor, "ParaStyleName", ParaStyled.paraStyle) @@ -1218,8 +1218,9 @@ class TextElement(ParaStyled): def write(self, textRange): textRange.String = self.text - if not self.text == "": - super(TextElement,self).write(textRange) + #COMMENTED + #if not self.text == "": + # super(TextElement,self).write(textRange) ''' A Text element which, if the text to write is empty (null or "") diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialog.py b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialog.py index 6d19ebb48a0b..1090717e4fc7 100644 --- a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialog.py +++ b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialog.py @@ -130,11 +130,12 @@ class AgendaWizardDialog(WizardDialog): self.resources.reslblTitle2_value, True,91, 8, 2, 200,212)) self.insertLabel("lblDate", self.PROPS_TEXT, (8, self.resources.reslblDate_value, 97, 32, 2, 201,66)) - self.txtDate = self.insertDateField("txtDate", None, self.PROPS_LIST, + self.txtDate = self.insertDateField( + "txtDate", TXTDATE_TEXT_CHANGED, self.PROPS_LIST, (True, 12, TXTDATE_HID,166,30, 2, 202,70), self) self.insertLabel("lblTime", self.PROPS_TEXT, (8, self.resources.reslblTime_value, 97, 50, 2, 203, 66)) - self.txtTime = self.insertTimeField("txtTime", None, + self.txtTime = self.insertTimeField("txtTime", TXTTIME_TEXT_CHANGED, (PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, @@ -146,7 +147,8 @@ class AgendaWizardDialog(WizardDialog): (12, TXTTIME_HID, 166, 48, 2, True, 204,70), self) self.insertLabel("lblTitle", self.PROPS_TEXT, (8, self.resources.reslblTitle_value, 97, 68, 2, 205,66)) - self.txtTitle = self.insertTextField("txtTitle", None, + self.txtTitle = self.insertTextField( + "txtTitle", TXTTITLE_TEXT_CHANGED, (PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_MULTILINE, @@ -158,7 +160,8 @@ class AgendaWizardDialog(WizardDialog): (26, TXTTITLE_HID, True, 166, 66, 2, 206, 138), self) self.insertLabel("lblLocation", self.PROPS_TEXT, (8, self.resources.reslblLocation_value, 97, 100, 2, 207, 66)) - self.cbLocation = self.insertTextField("cbLocation", None, + self.cbLocation = self.insertTextField( + "cbLocation", TXTLOCATION_TEXT_CHANGED, (PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_MULTILINE, diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogConst.py b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogConst.py index c97501cbb944..2ad9cca1cd1a 100644 --- a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogConst.py +++ b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogConst.py @@ -1,5 +1,9 @@ from common.HelpIds import HelpIds +TXTTITLE_TEXT_CHANGED = "txtTitleTextChanged" +TXTDATE_TEXT_CHANGED = "txtDateTextChanged" +TXTTIME_TEXT_CHANGED = "txtTimeTextChanged" +TXTLOCATION_TEXT_CHANGED = "txtLocationTextChanged" CHKUSEMEETINGTYPE_ITEM_CHANGED = "chkUseMeetingTypeItemChanged" CHKUSEREAD_ITEM_CHANGED = "chkUseReadItemChanged" CHKUSEBRING_ITEM_CHANGED = "chkUseBringItemChanged" diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py index 0cedfb02aaee..6d85b27dfd5c 100644 --- a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py +++ b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.py @@ -267,6 +267,19 @@ class AgendaWizardDialogImpl(AgendaWizardDialog): title = Helper.getUnoPropertyValue(getModel(txtTemplateName), "Text") self.agendaTemplate.setTemplateTitle(title) + #textFields listeners + def txtTitleTextChanged(self): + AgendaTemplate.redrawTitle("txtTitle") + + def txtDateTextChanged(self): + AgendaTemplate.redrawTitle("txtDate") + + def txtTimeTextChanged(self): + AgendaTemplate.redrawTitle("txtTime") + + def txtLocationTextChanged(self): + AgendaTemplate.redrawTitle("cbLocation") + #checkbox listeners def chkUseMeetingTypeItemChanged(self): AgendaTemplate.redraw(FILLIN_MEETING_TYPE) diff --git a/wizards/com/sun/star/wizards/fax/FaxWizardDialog.py b/wizards/com/sun/star/wizards/fax/FaxWizardDialog.py index e4295a0d025f..644f08a228db 100644 --- a/wizards/com/sun/star/wizards/fax/FaxWizardDialog.py +++ b/wizards/com/sun/star/wizards/fax/FaxWizardDialog.py @@ -312,8 +312,7 @@ class FaxWizardDialog(WizardDialog): PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH), - (12, TXTSENDERNAME_HID, 182, 67, 3, - 17, 119), self) + (12, TXTSENDERNAME_HID, 182, 67, 3, 17, 119), self) self.txtSenderStreet = self.insertTextField("txtSenderStreet", TXTSENDERSTREET_TEXT_CHANGED, (PropertyNames.PROPERTY_HEIGHT, @@ -323,8 +322,7 @@ class FaxWizardDialog(WizardDialog): PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH), - (12, TXTSENDERSTREET_HID, 182, 81, 3, - 18, 119), self) + (12, TXTSENDERSTREET_HID, 182, 81, 3, 18, 119), self) self.txtSenderPostCode = self.insertTextField("txtSenderPostCode", TXTSENDERPOSTCODE_TEXT_CHANGED, (PropertyNames.PROPERTY_HEIGHT, @@ -334,8 +332,7 @@ class FaxWizardDialog(WizardDialog): PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH), - (12, TXTSENDERPOSTCODE_HID, 182, 95, 3, - 19, 25), self) + (12, TXTSENDERPOSTCODE_HID, 182, 95, 3, 19, 25), self) self.txtSenderState = self.insertTextField("txtSenderState", TXTSENDERSTATE_TEXT_CHANGED, (PropertyNames.PROPERTY_HEIGHT, @@ -345,8 +342,7 @@ class FaxWizardDialog(WizardDialog): PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH), - (12, TXTSENDERSTATE_HID, 211, 95, 3, - 20, 21), self) + (12, TXTSENDERSTATE_HID, 211, 95, 3, 20, 21), self) self.txtSenderCity = self.insertTextField("txtSenderCity", TXTSENDERCITY_TEXT_CHANGED, (PropertyNames.PROPERTY_HEIGHT, @@ -356,8 +352,7 @@ class FaxWizardDialog(WizardDialog): PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH), - (12, TXTSENDERCITY_HID, 236, 95, 3, - 21, 65), self) + (12, TXTSENDERCITY_HID, 236, 95, 3, 21, 65), self) self.txtSenderFax = self.insertTextField("txtSenderFax", TXTSENDERFAX_TEXT_CHANGED, (PropertyNames.PROPERTY_HEIGHT, @@ -367,8 +362,7 @@ class FaxWizardDialog(WizardDialog): PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH), - (12, TXTSENDERFAX_HID, 182, 109, 3, - 22, 119), self) + (12, TXTSENDERFAX_HID, 182, 109, 3, 22, 119), self) self.optReceiverPlaceholder = self.insertRadioButton( "optReceiverPlaceholder", OPTRECEIVERPLACEHOLDER_ITEM_CHANGED, @@ -421,8 +415,7 @@ class FaxWizardDialog(WizardDialog): PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH), - (8, self.resources.reslblSenderName_value, 113, 69, 3, - 52, 68)) + (8, self.resources.reslblSenderName_value, 113, 69, 3, 52, 68)) self.insertLabel("lblSenderStreet", (PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, @@ -431,8 +424,7 @@ class FaxWizardDialog(WizardDialog): PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH), - (8, self.resources.reslblSenderStreet_value, 113, 82, 3, - 53, 68)) + (8, self.resources.reslblSenderStreet_value, 113, 82, 3, 53, 68)) self.insertLabel("lblPostCodeCity", (PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, @@ -441,8 +433,7 @@ class FaxWizardDialog(WizardDialog): PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH), - (8, self.resources.reslblPostCodeCity_value, - 113, 97, 3, 54, 68)) + (8, self.resources.reslblPostCodeCity_value, 113, 97, 3, 54, 68)) self.insertLabel("lblTitle4", ("FontDescriptor", PropertyNames.PROPERTY_HEIGHT, |