Overview
Comment: | [lo] lexicon editor: import dictionary |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | lo | multid |
Files: | files | file ages | folders |
SHA3-256: |
635fcc243bfd87953ce1b2511f844393 |
User & Date: | olr on 2018-03-28 10:53:07 |
Other Links: | branch diff | manifest | tags |
Context
2018-03-28
| ||
13:15 | [tb] lexicon editor: import dictionary check-in: 81f4f65958 user: olr tags: tb, multid | |
10:53 | [lo] lexicon editor: import dictionary check-in: 635fcc243b user: olr tags: lo, multid | |
08:56 | [lo] lexicon editor: strings update check-in: 79e0f99030 user: olr tags: lo, multid | |
Changes
Modified gc_lang/fr/oxt/DictOptions/LexiconEditor.py from [fa7335a6fb] to [2bb83eccad].
︙ | ︙ | |||
23 24 25 26 27 28 29 | 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 | | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 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 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() |
︙ | ︙ | |||
151 152 153 154 155 156 157 | #### Dictionary section self._addWidget("dictionary_section", 'FixedLine', nX1, nY0, 180, nHeight, Label = self.dUI.get("dictionary_section", "#err"), FontDescriptor = xFDTitle, TextColor = 0x000088) self._addWidget("save_date_label", 'FixedText', nXB, nY0+2, 80, nHeight, Label = self.dUI.get("save_date_label", "#err"), FontDescriptor = xFDSubTitle, TextColor = 0x000088) self._addWidget("num_of_entries_label2", 'FixedText', nXC, nY0+2, 65, nHeight, Label = self.dUI.get("num_of_entries_label", "#err"), FontDescriptor = xFDSubTitle, TextColor = 0x000088) self.xDateDic = self._addWidget("save_date", 'FixedText', nXB+85, nY0+2, 75, nHeight, Label = self.dUI.get("void", "#err"), FontDescriptor = xFDSubTitle, TextColor = 0x000088) self.xNumDic = self._addWidget("num_of_entries2", 'FixedText', nXC+70, nY0+2, 45, nHeight, Label = "0", FontDescriptor = xFDSubTitle, TextColor = 0x000088) | > | | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | #### Dictionary section self._addWidget("dictionary_section", 'FixedLine', nX1, nY0, 180, nHeight, Label = self.dUI.get("dictionary_section", "#err"), FontDescriptor = xFDTitle, TextColor = 0x000088) self._addWidget("save_date_label", 'FixedText', nXB, nY0+2, 80, nHeight, Label = self.dUI.get("save_date_label", "#err"), FontDescriptor = xFDSubTitle, TextColor = 0x000088) self._addWidget("num_of_entries_label2", 'FixedText', nXC, nY0+2, 65, nHeight, Label = self.dUI.get("num_of_entries_label", "#err"), FontDescriptor = xFDSubTitle, TextColor = 0x000088) self.xDateDic = self._addWidget("save_date", 'FixedText', nXB+85, nY0+2, 75, nHeight, Label = self.dUI.get("void", "#err"), FontDescriptor = xFDSubTitle, TextColor = 0x000088) self.xNumDic = self._addWidget("num_of_entries2", 'FixedText', nXC+70, nY0+2, 45, nHeight, Label = "0", FontDescriptor = xFDSubTitle, TextColor = 0x000088) self.xImport = self._addWidget('import_button', 'Button', self.xDialog.Width-90, nY0, 40, 12, Label = self.dUI.get('import_button', "#err"), FontDescriptor = xFDSubTitle, TextColor = 0x000055) self.xExport = self._addWidget('export_button', 'Button', self.xDialog.Width-50, nY0, 40, 12, Label = self.dUI.get('export_button', "#err"), FontDescriptor = xFDSubTitle, TextColor = 0x000055) #### Add word self._addWidget("add_section", 'FixedLine', nX1, nY1, 180, nHeight, Label = self.dUI.get("add_section", "#err"), FontDescriptor = xFDTitle) self.xLemma = self._addWidget('lemma', 'Edit', nX1, nY1+10, 110, 14, FontDescriptor = xFDTitle) self._addWidget('search_button', 'Button', nX1+115, nY1+11, 45, 12, Label = self.dUI.get('search_button', "#err"), FontDescriptor = xFDSubTitle, TextColor = 0x555500) self._addWidget('information_button', 'Button', nX1+165, nY1+11, 15, 12, Label = self.dUI.get('information_button', "#err"), FontDescriptor = xFDSubTitle, TextColor = 0x555500) |
︙ | ︙ | |||
272 273 274 275 276 277 278 279 280 281 282 283 284 285 | 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) | > > | 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | 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('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) |
︙ | ︙ | |||
340 341 342 343 344 345 346 | xDialog = SearchWords.SearchWords(self.ctx) xDialog.run(self.sLang, self.oPersonalDicJSON) def launchTagsInfo (self): xDialog = TagsInfo.TagsInfo(self.ctx) xDialog.run(self.sLang) | | > > | | > | | < | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > | 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | xDialog = SearchWords.SearchWords(self.ctx) xDialog.run(self.sLang, self.oPersonalDicJSON) def launchTagsInfo (self): xDialog = TagsInfo.TagsInfo(self.ctx) xDialog.run(self.sLang) #@_waitPointer (don’t: strange behavior when dialog is not finished) def loadLexicon (self): xGridDataModel = self.xGridModelLex.GridDataModel xGridDataModel.removeAllRows() xChild = self.xSettingNode.getByName("o_fr") sJSON = xChild.getPropertyValue("personal_dic") if sJSON: try: self.oPersonalDicJSON = json.loads(sJSON) oIBDAWG = ibdawg.IBDAWG(self.oPersonalDicJSON) for i, aEntry in enumerate(oIBDAWG.select()): xGridDataModel.addRow(i, aEntry) self.xNumLex.Label = str(i) self.xNumDic.Label = str(i) self.xDateDic.Label = oIBDAWG.sDate except: sMessage = self.dUI.get('not_loaded', "#err") sMessage += traceback.format_exc() MessageBox(self.xDocument, sMessage, self.dUI.get('load_title', "#err"), ERRORBOX) else: self.xNumLex.Label = 0 self.xNumDic.Label = 0 self.xDateDic.Label = self.dUI.get("void", "#err") @_waitPointer def importDictionary (self): spfImported = os.path.join(os.environ['USERPROFILE'], "fr.personal.json") if os.path.isfile(spfImported): with open(spfImported, "r", encoding="utf-8") as hDst: sJSON = hDst.read() try: sTest = json.loads(sJSON) except: sMessage = self.dUI.get('wrong_json', "#err_msg: %s") % spfImported MessageBox(self.xDocument, sMessage, self.dUI.get('import_title', "#err"), ERRORBOX) else: xChild = self.xSettingNode.getByName("o_fr") xChild.setPropertyValue("personal_dic", sJSON) self.loadLexicon() else: sMessage = self.dUI.get('file_not_found', "#err_msg: %s") % spfImported MessageBox(self.xDocument, sMessage, self.dUI.get('import_title', "#err"), ERRORBOX) @_waitPointer def saveLexicon (self): xGridDataModel = self.xGridModelLex.GridDataModel lEntry = [] for i in range(xGridDataModel.RowCount): lEntry.append(xGridDataModel.getRowData(i)) |
︙ | ︙ | |||
385 386 387 388 389 390 391 392 393 | 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() | > | < < < < | 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | 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") MessageBox(self.xDocument, sMessage, self.dUI.get('export_title', "#err")) except: sMessage = traceback.format_exc() MessageBox(self.xDocument, sMessage, self.dUI.get('export_title', "#err"), ERRORBOX) # 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() def _getRadioValue (self, *args): for x in args: if x.State: return x.HelpText return None @_waitPointer |
︙ | ︙ |
Modified gc_lang/fr/oxt/DictOptions/lxe_strings.py from [c8eb10a5d4] to [0d97dfb001].
︙ | ︙ | |||
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | "delete_button": "Supprimer la sélection", "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 "close_button": "Fermer", ## "verb_information": "" | > > > > > > | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | "delete_button": "Supprimer la sélection", "save_button": "Enregistrer", # Dictionary "dictionary_section": "Dictionnaire personnel", "save_date_label": "Date d’enregistrement :", "num_of_entries_label": "Nombre d’entrées :", "import_button": "Importer", "import_title": "Importation du dictionnaire", "export_button": "Exporter", "export_title": "Exportation du dictionnaire", "export_message": "Fichier exporté : ‹%s›", "empty_dictionary": "Le dictionnaire est vide. Aucun fichier créé.", "file_not_found": "Le fichier ‹%s› ne semble pas exister.", "wrong_json": "Le fichier ‹%s› n’est pas un fichier JSON valide.", "load_title": "Chargement du dictionnaire.", "not_loaded": "Le fichier n’a pas pu être chargé.\n", "void": "[néant]", # Close button "close_button": "Fermer", ## "verb_information": "" |
︙ | ︙ |