18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
import grammalecte.fr.conj_generator as conjgen
import SearchWords
import TagsInfo
from com.sun.star.task import XJobExecutor
from com.sun.star.awt import XActionListener
from com.sun.star.awt import XKeyListener
from com.sun.star.awt.MessageBoxButtons import BUTTONS_OK
# BUTTONS_OK, BUTTONS_OK_CANCEL, BUTTONS_YES_NO, BUTTONS_YES_NO_CANCEL, BUTTONS_RETRY_CANCEL, BUTTONS_ABORT_IGNORE_RETRY
# DEFAULT_BUTTON_OK, DEFAULT_BUTTON_CANCEL, DEFAULT_BUTTON_RETRY, DEFAULT_BUTTON_YES, DEFAULT_BUTTON_NO, DEFAULT_BUTTON_IGNORE
from com.sun.star.awt.MessageBoxType import INFOBOX, ERRORBOX # MESSAGEBOX, INFOBOX, WARNINGBOX, ERRORBOX, QUERYBOX
|
>
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
import grammalecte.fr.conj_generator as conjgen
import SearchWords
import TagsInfo
from com.sun.star.task import XJobExecutor
from com.sun.star.awt import XActionListener
from com.sun.star.awt import XTopWindowListener
from com.sun.star.awt import XKeyListener
from com.sun.star.awt.MessageBoxButtons import BUTTONS_OK
# BUTTONS_OK, BUTTONS_OK_CANCEL, BUTTONS_YES_NO, BUTTONS_YES_NO_CANCEL, BUTTONS_RETRY_CANCEL, BUTTONS_ABORT_IGNORE_RETRY
# DEFAULT_BUTTON_OK, DEFAULT_BUTTON_CANCEL, DEFAULT_BUTTON_RETRY, DEFAULT_BUTTON_YES, DEFAULT_BUTTON_NO, DEFAULT_BUTTON_IGNORE
from com.sun.star.awt.MessageBoxType import INFOBOX, ERRORBOX # MESSAGEBOX, INFOBOX, WARNINGBOX, ERRORBOX, QUERYBOX
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
x.setPointer(xPointer)
self.xContainer.setVisible(True) # seems necessary to refresh the dialog box and text widgets (why?)
# return
return result
return wrapper
class LexiconEditor (unohelper.Base, XActionListener, XKeyListener, XJobExecutor):
def __init__ (self, ctx):
self.ctx = ctx
self.xSvMgr = self.ctx.ServiceManager
self.xDesktop = self.xSvMgr.createInstanceWithContext("com.sun.star.frame.Desktop", self.ctx)
self.xDocument = self.xDesktop.getCurrentComponent()
self.xContainer = None
|
|
|
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
x.setPointer(xPointer)
self.xContainer.setVisible(True) # seems necessary to refresh the dialog box and text widgets (why?)
# return
return result
return wrapper
class LexiconEditor (unohelper.Base, XActionListener, XTopWindowListener, XKeyListener, XJobExecutor):
def __init__ (self, ctx):
self.ctx = ctx
self.xSvMgr = self.ctx.ServiceManager
self.xDesktop = self.xSvMgr.createInstanceWithContext("com.sun.star.frame.Desktop", self.ctx)
self.xDocument = self.xDesktop.getCurrentComponent()
self.xContainer = None
|
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
|
self.xContainer.getControl('save_button').setActionCommand('Save')
self.xContainer.getControl('import_button').addActionListener(self)
self.xContainer.getControl('import_button').setActionCommand('Import')
self.xContainer.getControl('export_button').addActionListener(self)
self.xContainer.getControl('export_button').setActionCommand('Export')
self.xContainer.getControl('close_button').addActionListener(self)
self.xContainer.getControl('close_button').setActionCommand('Close')
self.xContainer.setVisible(False)
xToolkit = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.ExtToolkit', self.ctx)
self.xContainer.createPeer(xToolkit, None)
self.xContainer.execute()
def _createKeyListeners (self, lNames, sAction):
for sName in lNames:
self.xContainer.getControl(sName).addKeyListener(self)
def _createActionListeners (self, lNames, sAction):
for sName in lNames:
|
>
|
|
|
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
|
self.xContainer.getControl('save_button').setActionCommand('Save')
self.xContainer.getControl('import_button').addActionListener(self)
self.xContainer.getControl('import_button').setActionCommand('Import')
self.xContainer.getControl('export_button').addActionListener(self)
self.xContainer.getControl('export_button').setActionCommand('Export')
self.xContainer.getControl('close_button').addActionListener(self)
self.xContainer.getControl('close_button').setActionCommand('Close')
self.xContainer.addTopWindowListener(self) # listener with XTopWindowListener methods
self.xContainer.setVisible(True) # True for non modal dialog
xToolkit = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.ExtToolkit', self.ctx)
self.xContainer.createPeer(xToolkit, None)
#self.xContainer.execute() # For modal dialog
def _createKeyListeners (self, lNames, sAction):
for sName in lNames:
self.xContainer.getControl(sName).addKeyListener(self)
def _createActionListeners (self, lNames, sAction):
for sName in lNames:
|
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
|
elif xActionEvent.ActionCommand == "Import":
self.importDictionary()
elif xActionEvent.ActionCommand == "Export":
self.exportDictionary()
elif xActionEvent.ActionCommand == 'Info':
pass
elif xActionEvent.ActionCommand == "Close":
self.xContainer.endExecute()
except:
traceback.print_exc()
# XKeyListener
def keyPressed (self, xKeyEvent):
pass
def keyReleased (self, xKeyEvent):
self.updateGenWords()
|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
|
elif xActionEvent.ActionCommand == "Import":
self.importDictionary()
elif xActionEvent.ActionCommand == "Export":
self.exportDictionary()
elif xActionEvent.ActionCommand == 'Info':
pass
elif xActionEvent.ActionCommand == "Close":
self.xContainer.dispose() # Non modal dialog
#self.xContainer.endExecute() # Modal dialog
except:
traceback.print_exc()
# XTopWindowListener (useful for non modal dialog only)
def windowOpened (self, xEvent):
return
def windowClosing (self, xEvent):
self.xContainer.dispose() # Non modal dialog
def windowClosed (self, xEvent):
return
def windowMinimized (self, xEvent):
return
def windowNormalized (self, xEvent):
return
def windowActivated (self, xEvent):
return
def windowDeactivated (self, xEvent):
return
# XKeyListener
def keyPressed (self, xKeyEvent):
pass
def keyReleased (self, xKeyEvent):
self.updateGenWords()
|