Kaydet (Commit) ec20c94a authored tarafından Xisco Fauli's avatar Xisco Fauli

pyagenda: now it's possible to call the wizard remotely

Change-Id: I25c49f58e580a0d08a2b0d0fce9d76e372c69d19
üst 02dd4619
...@@ -16,12 +16,13 @@ ...@@ -16,12 +16,13 @@
# the License at http://www.apache.org/licenses/LICENSE-2.0 . # the License at http://www.apache.org/licenses/LICENSE-2.0 .
# #
import uno import uno
from TemplateConsts import * from .TemplateConsts import *
from threading import RLock from threading import RLock
from wizards.text.TextDocument import * from ..text.TextDocument import *
from wizards.common.FileAccess import FileAccess from ..common.FileAccess import FileAccess
from wizards.text.TextSectionHandler import TextSectionHandler from ..text.TextSectionHandler import TextSectionHandler
from TopicsControl import TopicsControl from .TopicsControl import TopicsControl
from datetime import date as dateTimeObject from datetime import date as dateTimeObject
from com.sun.star.text.PlaceholderType import TEXT from com.sun.star.text.PlaceholderType import TEXT
......
...@@ -17,64 +17,62 @@ ...@@ -17,64 +17,62 @@
# #
from wizards.common.HelpIds import HelpIds from wizards.common.HelpIds import HelpIds
TXTTITLE_TEXT_CHANGED = "txtTitleTextChanged"
TXTDATE_TEXT_CHANGED = "txtDateTextChanged"
TXTTIME_TEXT_CHANGED = "txtTimeTextChanged"
TXTLOCATION_TEXT_CHANGED = "txtLocationTextChanged"
CHKMINUTES_ITEM_CHANGED = "chkMinutesItemChanged"
CHKUSEMEETINGTYPE_ITEM_CHANGED = "chkUseMeetingTypeItemChanged"
CHKUSEREAD_ITEM_CHANGED = "chkUseReadItemChanged"
CHKUSEBRING_ITEM_CHANGED = "chkUseBringItemChanged"
CHKUSENOTES_ITEM_CHANGED = "chkUseNotesItemChanged"
CHKUSECALLEDBYNAME_ITEM_CHANGED = "chkUseCalledByItemChanged"
CHKUSEFACILITATOR_ITEM_CHANGED = "chkUseFacilitatorItemChanged"
CHKUSENOTETAKER_ITEM_CHANGED = "chkUseNoteTakerItemChanged"
CHKUSETIMEKEEPER_ITEM_CHANGED = "chkUseTimeKeeperItemChanged"
CHKUSEATTENDEES_ITEM_CHANGED = "chkUseAttendeesItemChanged"
CHKUSEOBSERVERS_ITEM_CHANGED = "chkUseObserversItemChanged"
CHKUSERESOURCEPERSONS_ITEM_CHANGED = "chkUseResourcePersonsItemChanged"
LISTPAGEDESIGN_ACTION_PERFORMED = "pageDesignChanged"
TXTTEMPLATENAME_TEXT_CHANGED = "templateTitleChanged"
BTNTEMPLATEPATH_ACTION_PERFORMED = "saveAs"
BTNINSERT_ACTION_PERFORMED = "insertRow"
BTNREMOVE_ACTION_PERFORMED = "removeRow"
BTNUP_ACTION_PERFORMED = "rowUp"
BTNDOWN_ACTION_PERFORMED = "rowDown"
INFO_IMAGE_URL = "private:resource/dbu/image/19205"
HID = 41051 HID = 41051
LISTPAGEDESIGN_HID = HelpIds.getHelpIdString(HID + 6) class AgendaWizardDialogConst:
CHKMINUTES_HID = HelpIds.getHelpIdString(HID + 7)
TXTTIME_HID = HelpIds.getHelpIdString(HID + 8) TXTTITLE_TEXT_CHANGED = "txtTitleTextChanged"
TXTDATE_HID = HelpIds.getHelpIdString(HID + 9) TXTDATE_TEXT_CHANGED = "txtDateTextChanged"
TXTTITLE_HID = HelpIds.getHelpIdString(HID + 10) TXTTIME_TEXT_CHANGED = "txtTimeTextChanged"
CBLOCATION_HID = HelpIds.getHelpIdString(HID + 11) TXTLOCATION_TEXT_CHANGED = "txtLocationTextChanged"
CHKMINUTES_ITEM_CHANGED = "chkMinutesItemChanged"
CHKUSEMEETINGTYPE_ITEM_CHANGED = "chkUseMeetingTypeItemChanged"
CHKUSEREAD_ITEM_CHANGED = "chkUseReadItemChanged"
CHKUSEBRING_ITEM_CHANGED = "chkUseBringItemChanged"
CHKUSENOTES_ITEM_CHANGED = "chkUseNotesItemChanged"
CHKUSECALLEDBYNAME_ITEM_CHANGED = "chkUseCalledByItemChanged"
CHKUSEFACILITATOR_ITEM_CHANGED = "chkUseFacilitatorItemChanged"
CHKUSENOTETAKER_ITEM_CHANGED = "chkUseNoteTakerItemChanged"
CHKUSETIMEKEEPER_ITEM_CHANGED = "chkUseTimeKeeperItemChanged"
CHKUSEATTENDEES_ITEM_CHANGED = "chkUseAttendeesItemChanged"
CHKUSEOBSERVERS_ITEM_CHANGED = "chkUseObserversItemChanged"
CHKUSERESOURCEPERSONS_ITEM_CHANGED = "chkUseResourcePersonsItemChanged"
LISTPAGEDESIGN_ACTION_PERFORMED = "pageDesignChanged"
TXTTEMPLATENAME_TEXT_CHANGED = "templateTitleChanged"
BTNTEMPLATEPATH_ACTION_PERFORMED = "saveAs"
BTNINSERT_ACTION_PERFORMED = "insertRow"
BTNREMOVE_ACTION_PERFORMED = "removeRow"
BTNUP_ACTION_PERFORMED = "rowUp"
BTNDOWN_ACTION_PERFORMED = "rowDown"
CHKMEETINGTITLE_HID = HelpIds.getHelpIdString(HID + 12) LISTPAGEDESIGN_HID = HelpIds.getHelpIdString(HID + 6)
CHKREAD_HID = HelpIds.getHelpIdString(HID + 13) CHKMINUTES_HID = HelpIds.getHelpIdString(HID + 7)
CHKBRING_HID = HelpIds.getHelpIdString(HID + 14) TXTTIME_HID = HelpIds.getHelpIdString(HID + 8)
CHKNOTES_HID = HelpIds.getHelpIdString(HID + 15) TXTDATE_HID = HelpIds.getHelpIdString(HID + 9)
TXTTITLE_HID = HelpIds.getHelpIdString(HID + 10)
CBLOCATION_HID = HelpIds.getHelpIdString(HID + 11)
CHKCONVENEDBY_HID = HelpIds.getHelpIdString(HID + 16) CHKMEETINGTITLE_HID = HelpIds.getHelpIdString(HID + 12)
CHKPRESIDING_HID = HelpIds.getHelpIdString(HID + 17) CHKREAD_HID = HelpIds.getHelpIdString(HID + 13)
CHKNOTETAKER_HID = HelpIds.getHelpIdString(HID + 18) CHKBRING_HID = HelpIds.getHelpIdString(HID + 14)
CHKTIMEKEEPER_HID = HelpIds.getHelpIdString(HID + 19) CHKNOTES_HID = HelpIds.getHelpIdString(HID + 15)
CHKATTENDEES_HID = HelpIds.getHelpIdString(HID + 20)
CHKOBSERVERS_HID = HelpIds.getHelpIdString(HID + 21)
CHKRESOURCEPERSONS_HID = HelpIds.getHelpIdString(HID + 22)
TXTTEMPLATENAME_HID = HelpIds.getHelpIdString(HID + 23) CHKCONVENEDBY_HID = HelpIds.getHelpIdString(HID + 16)
TXTTEMPLATEPATH_HID = HelpIds.getHelpIdString(HID + 24) CHKPRESIDING_HID = HelpIds.getHelpIdString(HID + 17)
BTNTEMPLATEPATH_HID = HelpIds.getHelpIdString(HID + 25) CHKNOTETAKER_HID = HelpIds.getHelpIdString(HID + 18)
CHKTIMEKEEPER_HID = HelpIds.getHelpIdString(HID + 19)
CHKATTENDEES_HID = HelpIds.getHelpIdString(HID + 20)
CHKOBSERVERS_HID = HelpIds.getHelpIdString(HID + 21)
CHKRESOURCEPERSONS_HID = HelpIds.getHelpIdString(HID + 22)
OPTCREATEAGENDA_HID = HelpIds.getHelpIdString(HID + 26) TXTTEMPLATENAME_HID = HelpIds.getHelpIdString(HID + 23)
OPTMAKECHANGES_HID = HelpIds.getHelpIdString(HID + 27) TXTTEMPLATEPATH_HID = HelpIds.getHelpIdString(HID + 24)
BTNTEMPLATEPATH_HID = HelpIds.getHelpIdString(HID + 25)
BTNINSERT_HID = HelpIds.getHelpIdString(HID + 28) OPTCREATEAGENDA_HID = HelpIds.getHelpIdString(HID + 26)
BTNREMOVE_HID = HelpIds.getHelpIdString(HID + 29) OPTMAKECHANGES_HID = HelpIds.getHelpIdString(HID + 27)
BTNUP_HID = HelpIds.getHelpIdString(HID + 30)
BTNDOWN_HID = HelpIds.getHelpIdString(HID + 31)
LAST_HID = HID + 32 BTNINSERT_HID = HelpIds.getHelpIdString(HID + 28)
BTNREMOVE_HID = HelpIds.getHelpIdString(HID + 29)
BTNUP_HID = HelpIds.getHelpIdString(HID + 30)
BTNDOWN_HID = HelpIds.getHelpIdString(HID + 31)
...@@ -15,14 +15,19 @@ ...@@ -15,14 +15,19 @@
# except in compliance with the License. You may obtain a copy of # except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 . # the License at http://www.apache.org/licenses/LICENSE-2.0 .
# #
from AgendaWizardDialog import * import traceback
from AgendaTemplate import * from .AgendaWizardDialog import AgendaWizardDialog
from .AgendaWizardDialogConst import HID
from .AgendaTemplate import AgendaTemplate, TopicsControl, FileAccess
from CGAgenda import CGAgenda from CGAgenda import CGAgenda
from wizards.ui.PathSelection import PathSelection from ..ui.PathSelection import PathSelection
from wizards.ui.event.UnoDataAware import UnoDataAware from ..ui.event.UnoDataAware import UnoDataAware
from wizards.ui.event.RadioDataAware import RadioDataAware from ..ui.event.RadioDataAware import RadioDataAware
from wizards.common.NoValidPathException import NoValidPathException from ..common.NoValidPathException import NoValidPathException
from wizards.common.SystemDialog import SystemDialog from ..common.SystemDialog import SystemDialog
from ..common.Desktop import Desktop
from ..common.HelpIds import HelpIds
from ..common.Configuration import Configuration
from com.sun.star.view.DocumentZoomType import OPTIMAL from com.sun.star.view.DocumentZoomType import OPTIMAL
from com.sun.star.awt.VclWindowPeerAttribute import YES_NO, DEF_NO from com.sun.star.awt.VclWindowPeerAttribute import YES_NO, DEF_NO
...@@ -43,31 +48,20 @@ class AgendaWizardDialogImpl(AgendaWizardDialog): ...@@ -43,31 +48,20 @@ class AgendaWizardDialogImpl(AgendaWizardDialog):
def leaveStep(self, OldStep, NewStep): def leaveStep(self, OldStep, NewStep):
pass pass
'''
used in developement to start the wizard
'''
@classmethod @classmethod
def main(self, args): def main(self):
ConnectStr = \ #Call the wizard remotely(see README)
"uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext"
try: try:
ConnectStr = \
"uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext"
xLocMSF = Desktop.connect(ConnectStr) xLocMSF = Desktop.connect(ConnectStr)
wizard = AgendaWizardDialogImpl(xLocMSF) lw = AgendaWizardDialogImpl(xLocMSF)
wizard.startWizard() lw.startWizard()
except Exception, exception: except Exception as e:
traceback.print_exc() print ("Wizard failure exception " + str(type(e)) +
" message " + str(e) + " args " + str(e.args) +
''' traceback.format_exc())
read the configuration data, open the specified template,
initialize the template controller (AgendaTemplate) and
set the status of the displayed template to the one
read from the configuration.
build the dialog.
Synchronize the dialog to the same status (read from
the configuration).
show the dialog.
'''
def startWizard(self): def startWizard(self):
self.running = True self.running = True
...@@ -134,8 +128,7 @@ class AgendaWizardDialogImpl(AgendaWizardDialog): ...@@ -134,8 +128,7 @@ class AgendaWizardDialogImpl(AgendaWizardDialog):
self.myPathSelection.sDefaultDirectory = self.sUserTemplatePath self.myPathSelection.sDefaultDirectory = self.sUserTemplatePath
self.myPathSelection.sDefaultName = "myAgendaTemplate.ott" self.myPathSelection.sDefaultName = "myAgendaTemplate.ott"
self.myPathSelection.sDefaultFilter = "writer8_template" self.myPathSelection.sDefaultFilter = "writer8_template"
self.myPathSelection.addSelectionListener( self.myPathSelection.addSelectionListener(self)
self.myPathSelectionListener())
def initializePaths(self): def initializePaths(self):
try: try:
...@@ -173,7 +166,8 @@ class AgendaWizardDialogImpl(AgendaWizardDialog): ...@@ -173,7 +166,8 @@ class AgendaWizardDialogImpl(AgendaWizardDialog):
self.agenda.readConfiguration(root, "cp_") self.agenda.readConfiguration(root, "cp_")
self.setControlProperty( self.setControlProperty(
"listPageDesign", "StringItemList", tuple(self.agendaTemplates[0])) "listPageDesign", "StringItemList",
tuple(self.agendaTemplates.keys()))
self.checkSavePath() self.checkSavePath()
UnoDataAware.attachListBox( UnoDataAware.attachListBox(
self.agenda, "cp_AgendaType", self.listPageDesign, True).updateUI() self.agenda, "cp_AgendaType", self.listPageDesign, True).updateUI()
...@@ -271,7 +265,7 @@ class AgendaWizardDialogImpl(AgendaWizardDialog): ...@@ -271,7 +265,7 @@ class AgendaWizardDialogImpl(AgendaWizardDialog):
if AgendaWizardDialogImpl.pageDesign is not SelectedItemPos: if AgendaWizardDialogImpl.pageDesign is not SelectedItemPos:
AgendaWizardDialogImpl.pageDesign = SelectedItemPos AgendaWizardDialogImpl.pageDesign = SelectedItemPos
self.agendaTemplate.load( self.agendaTemplate.load(
self.agendaTemplates[1][SelectedItemPos], self.agendaTemplates.values()[SelectedItemPos],
self.topicsControl.scrollfields) self.topicsControl.scrollfields)
except Exception: except Exception:
traceback.print_exc() traceback.print_exc()
...@@ -422,7 +416,7 @@ class AgendaWizardDialogImpl(AgendaWizardDialog): ...@@ -422,7 +416,7 @@ class AgendaWizardDialogImpl(AgendaWizardDialog):
if fileAccess.exists(self.sPath, True): if fileAccess.exists(self.sPath, True):
answer = SystemDialog.showMessageBox( answer = SystemDialog.showMessageBox(
self.xMSF, "MessBox", YES_NO + DEF_NO, self.xMSF, "MessBox", YES_NO + DEF_NO,
self.resources.resFileExists, self.resources.resOverwriteWarning,
self.xUnoDialog.Peer) self.xUnoDialog.Peer)
if answer == 3: if answer == 3:
# user said: no, do not overwrite # user said: no, do not overwrite
......
...@@ -166,5 +166,5 @@ class AgendaWizardDialogResources(Resource): ...@@ -166,5 +166,5 @@ class AgendaWizardDialogResources(Resource):
self.resButtonDown = self.getResText( self.resButtonDown = self.getResText(
AgendaWizardDialogResources.RID_AGENDAWIZARDDIALOG_START + 71) AgendaWizardDialogResources.RID_AGENDAWIZARDDIALOG_START + 71)
self.resFileExists = self.getResText( self.resOverwriteWarning = self.getResText(
AgendaWizardDialogResources.RID_COMMON_START + 19) AgendaWizardDialogResources.RID_COMMON_START + 19)
...@@ -16,11 +16,12 @@ ...@@ -16,11 +16,12 @@
# the License at http://www.apache.org/licenses/LICENSE-2.0 . # the License at http://www.apache.org/licenses/LICENSE-2.0 .
# #
from threading import RLock from threading import RLock
from CGTopic import CGTopic from .CGTopic import CGTopic
from wizards.ui.ControlScroller import * from ..ui.ControlScroller import *
from AgendaWizardDialogConst import LAST_HID from .AgendaWizardDialogConst import HID
from wizards.common.Properties import Properties from ..common.Properties import Properties
from wizards.ui.event.CommonListener import FocusListenerProcAdapter, KeyListenerProcAdapter from ..ui.event.CommonListener import FocusListenerProcAdapter, \
KeyListenerProcAdapter
from com.sun.star.awt.Key import DOWN, UP, TAB from com.sun.star.awt.Key import DOWN, UP, TAB
from com.sun.star.awt.KeyModifier import SHIFT, MOD1 from com.sun.star.awt.KeyModifier import SHIFT, MOD1
...@@ -115,7 +116,7 @@ class TopicsControl(ControlScroller): ...@@ -115,7 +116,7 @@ class TopicsControl(ControlScroller):
def __init__(self, dialog, xmsf, agenda): def __init__(self, dialog, xmsf, agenda):
try: try:
super(TopicsControl, self).__init__( super(TopicsControl, self).__init__(
dialog, xmsf, 5, 92, 38, 212, 5, 18, LAST_HID) dialog, xmsf, 5, 92, 38, 212, 5, 18, HID + 32)
self.initializeScrollFields(agenda) self.initializeScrollFields(agenda)
# set some focus listeners for TAB scroll down and up... # set some focus listeners for TAB scroll down and up...
# prepare scroll down on tab press... # prepare scroll down on tab press...
......
...@@ -307,7 +307,7 @@ class FileAccess(object): ...@@ -307,7 +307,7 @@ class FileAccess(object):
return False return False
@classmethod @classmethod
def getFolderTitles(self, xMSF, FilterName, FolderName, resDict): def getFolderTitles(self, xMSF, FilterName, FolderName, resDict=None):
#Returns and ordered dict containing the template's name and path #Returns and ordered dict containing the template's name and path
LocLayoutFiles = {} LocLayoutFiles = {}
...@@ -326,11 +326,14 @@ class FileAccess(object): ...@@ -326,11 +326,14 @@ class FileAccess(object):
fileName = self.getFilename(i) fileName = self.getFilename(i)
if FilterName is None or fileName.startswith(FilterName): if FilterName is None or fileName.startswith(FilterName):
xDocInterface.loadFromMedium(i, tuple()) xDocInterface.loadFromMedium(i, tuple())
if xDocInterface.Title in resDict: if resDict is None:
# localise string at runtime
title = resDict[xDocInterface.Title]
else:
title = xDocInterface.Title title = xDocInterface.Title
else:
if xDocInterface.Title in resDict:
# localise string at runtime
title = resDict[xDocInterface.Title]
else:
title = xDocInterface.Title
LocLayoutFiles[title] = i LocLayoutFiles[title] = i
except Exception, exception: except Exception, exception:
......
...@@ -20,7 +20,8 @@ from .UIConsts import UIConsts ...@@ -20,7 +20,8 @@ from .UIConsts import UIConsts
from ..common.Desktop import Desktop from ..common.Desktop import Desktop
from ..common.PropertyNames import PropertyNames from ..common.PropertyNames import PropertyNames
from .event.CommonListener import ItemListenerProcAdapter, \ from .event.CommonListener import ItemListenerProcAdapter, \
ActionListenerProcAdapter, TextListenerProcAdapter ActionListenerProcAdapter, TextListenerProcAdapter, \
AdjustmentListenerProcAdapter
''' '''
This class contains convenience methods for inserting components to a dialog. This class contains convenience methods for inserting components to a dialog.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment