Overview
Comment: | [lo] lexicon editor: export dictionary (sigh: file picker doesn’t work at all) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | lo | multid |
Files: | files | file ages | folders |
SHA3-256: |
d03e3c0ed1ecfd844b15faffc3032ce0 |
User & Date: | olr on 2018-03-27 14:48:23 |
Other Links: | branch diff | manifest | tags |
Context
2018-03-27
| ||
15:13 | [fx][tb][lo] lexicon editor: participe passé invariable check-in: 86b963906e user: olr tags: tb, fx, lo, multid | |
14:48 | [lo] lexicon editor: export dictionary (sigh: file picker doesn’t work at all) check-in: d03e3c0ed1 user: olr tags: lo, multid | |
13:01 | [lo] lexical editor: wait pointers check-in: 3a15f6b206 user: olr tags: lo, multid | |
Changes
Modified gc_lang/fr/oxt/DictOptions/LexiconEditor.py from [07ba5d540c] to [d7c0b13323].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | # Lexicon Editor # by Olivier R. # License: MPL 2 import unohelper import uno import json import re import traceback import helpers import lxe_strings import grammalecte.graphspell as sc import grammalecte.graphspell.dawg as dawg import grammalecte.graphspell.ibdawg as ibdawg import grammalecte.fr.conj as conj 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 def _waitPointer (funcDecorated): def wrapper (*args, **kwargs): # self is the first parameter if the decorator is applied on a object self = args[0] # before | > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | # Lexicon Editor # by Olivier R. # License: MPL 2 import unohelper import uno import json import re import os import traceback import helpers import lxe_strings import grammalecte.graphspell as sc import grammalecte.graphspell.dawg as dawg import grammalecte.graphspell.ibdawg as ibdawg import grammalecte.fr.conj as conj 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 # MESSAGEBOX, INFOBOX, WARNINGBOX, ERRORBOX, QUERYBOX def MessageBox (xDocument, sMsg, sTitle, nBoxType=INFOBOX, nBoxButtons=BUTTONS_OK): xParentWin = xDocument.CurrentController.Frame.ContainerWindow ctx = uno.getComponentContext() xToolkit = ctx.ServiceManager.createInstanceWithContext("com.sun.star.awt.Toolkit", ctx) xMsgBox = xToolkit.createMessageBox(xParentWin, nBoxType, nBoxButtons, sTitle, sMsg) return xMsgBox.execute() def _waitPointer (funcDecorated): def wrapper (*args, **kwargs): # self is the first parameter if the decorator is applied on a object self = args[0] # before |
︙ | ︙ | |||
259 260 261 262 263 264 265 266 267 268 269 270 271 272 | self.xContainer.getControl('information_button').setActionCommand('TagsInfo') self.xContainer.getControl('add_button').addActionListener(self) self.xContainer.getControl('add_button').setActionCommand('Add') self.xContainer.getControl('delete_button').addActionListener(self) self.xContainer.getControl('delete_button').setActionCommand('Delete') self.xContainer.getControl('save_button').addActionListener(self) self.xContainer.getControl('save_button').setActionCommand('Save') 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() | > > | 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | self.xContainer.getControl('information_button').setActionCommand('TagsInfo') self.xContainer.getControl('add_button').addActionListener(self) self.xContainer.getControl('add_button').setActionCommand('Add') self.xContainer.getControl('delete_button').addActionListener(self) self.xContainer.getControl('delete_button').setActionCommand('Delete') self.xContainer.getControl('save_button').addActionListener(self) self.xContainer.getControl('save_button').setActionCommand('Save') 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() |
︙ | ︙ | |||
294 295 296 297 298 299 300 301 302 303 304 305 306 307 | self.deleteSelectedEntries() elif xActionEvent.ActionCommand == "Save": self.saveLexicon() elif xActionEvent.ActionCommand == "Import": self.importDictionary() elif xActionEvent.ActionCommand == "Export": self.exportDictionary() elif xActionEvent.ActionCommand == "Close": self.xContainer.endExecute() except: traceback.print_exc() # XKeyListener def keyPressed (self, xKeyEvent): | > > | 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | self.deleteSelectedEntries() elif xActionEvent.ActionCommand == "Save": self.saveLexicon() 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): |
︙ | ︙ | |||
537 538 539 540 541 542 543 | self.xGridControlLex.deselectAllRows() self.xNumLex.Label = str(xGridDataModel.RowCount) @_waitPointer def importDictionary (self): pass | < > > > > > > > > > > > > > > > | | | | | | 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 | self.xGridControlLex.deselectAllRows() self.xNumLex.Label = str(xGridDataModel.RowCount) @_waitPointer def importDictionary (self): pass def exportDictionary (self): try: spfExported = os.path.join(os.environ['USERPROFILE'], "fr.personal.json") xChild = self.xSettingNode.getByName("o_fr") sJSON = xChild.getPropertyValue("personal_dic") if sJSON: with open(spfExported, "w", encoding="utf-8") as hDst: hDst.write(sJSON) sMessage = self.dUI.get('export_message', "#err_msg: %s") % spfExported else: sMessage = self.dUI.get('empty_dictionary', "#err") except: sMessage = traceback.format_exc() MessageBox(self.xDocument, sMessage, self.dUI.get('export_title', "#err")) # FilePicker doesn’t work at all… #xFilePicker = self.xSvMgr.createInstanceWithContext('com.sun.star.ui.dialogs.SystemFilePicker', self.ctx) #xFilePicker.appendFilter("Supported files", "*.json; *.bdic") #xFilePicker.setDisplayDirectory("") #xFilePicker.setMultiSelectionMode(True) #nResult = xFilePicker.execute() #if nResult == 1: #pass #lFile = xFilePicker.getSelectedFiles() #lFile = xFilePicker.getFiles() #g_ImplementationHelper = unohelper.ImplementationHelper() #g_ImplementationHelper.addImplementation(LexiconEditor, 'net.grammalecte.LexiconEditor', ('com.sun.star.task.Job',)) |
Modified gc_lang/fr/oxt/DictOptions/lxe_strings.py from [95dfd605af] to [d20d6fd400].
︙ | ︙ | |||
65 66 67 68 69 70 71 72 73 74 75 76 77 78 | "save_button": "Enregistrer", # Dictionary "dictionary_section": "Dictionnaire personnel", "save_date_label": "Date d’enregistrement :", "num_of_entries_label": "Nombre d’entrées :", "export_button": "Exporter", "void": "[néant]", # "close_button": "Fermer", }, # Traduction délibérément limitée "en": { | > > > | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | "save_button": "Enregistrer", # Dictionary "dictionary_section": "Dictionnaire personnel", "save_date_label": "Date d’enregistrement :", "num_of_entries_label": "Nombre d’entrées :", "export_button": "Exporter", "export_title": "Exportation du dictionnaire", "export_message": "Fichier exporté : ‹%s>", "empty_dictionary": "Le dictionnaire est vide. Aucun fichier créé.", "void": "[néant]", # "close_button": "Fermer", }, # Traduction délibérément limitée "en": { |
︙ | ︙ |