Grammalecte  Check-in [e2611084e9]

Overview
Comment:[lo] lexicon editor: ui rework
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | lo | multid
Files: files | file ages | folders
SHA3-256: e2611084e9583e535fc0cc8fab58617c7725c6234e08fc262696aa0b129ee7d1
User & Date: olr on 2018-03-10 21:07:58
Other Links: branch diff | manifest | tags
Context
2018-03-11
10:43
[lo] lexicon editor: update check-in: d5d52dde75 user: olr tags: lo, multid
2018-03-10
21:07
[lo] lexicon editor: ui rework check-in: e2611084e9 user: olr tags: lo, multid
04:38
[fr][bug] conj_generator: false -> False check-in: dc1776bb2d user: olr tags: fr, multid
Changes

Modified gc_lang/fr/oxt/DictOptions/LexiconEditor.py from [c2a8dfc686] to [e3eb9c5ac2].

93
94
95
96
97
98
99
100

101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

121

122
123
124
125
126
127
128
129
130
131
132








133
134
135
136
137
138
139
140
141
142
143
93
94
95
96
97
98
99

100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121

122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144

145
146
147
148
149
150
151







-
+




















+
-
+











+
+
+
+
+
+
+
+



-







    def run (self, sLang):
        # ui lang
        self.dUI = lxe_strings.getUI(sLang)

        # dialog
        self.xDialog = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialogModel', self.ctx)
        self.xDialog.Width = 570
        self.xDialog.Height = 292
        self.xDialog.Height = 305
        self.xDialog.Title = self.dUI.get('title', "#title#")
        xWindowSize = helpers.getWindowSize()
        self.xDialog.PositionX = int((xWindowSize.Width / 2) - (self.xDialog.Width / 2))
        self.xDialog.PositionY = int((xWindowSize.Height / 2) - (self.xDialog.Height / 2))

        # fonts
        xFDTitle = uno.createUnoStruct("com.sun.star.awt.FontDescriptor")
        xFDTitle.Height = 9
        xFDTitle.Weight = uno.getConstantByName("com.sun.star.awt.FontWeight.BOLD")
        xFDTitle.Name = "Verdana"
        
        xFDSubTitle = uno.createUnoStruct("com.sun.star.awt.FontDescriptor")
        xFDSubTitle.Height = 8
        xFDSubTitle.Weight = uno.getConstantByName("com.sun.star.awt.FontWeight.BOLD")
        xFDSubTitle.Name = "Verdana"

        # widget
        nX1 = 10
        nX2 = 20

        nY0 = 5
        nY1 = 5
        nY1 = nY0 + 13
        nY2 = nY1 + 25 # nom commun
        nY3 = nY2 + 95 # nom propre
        nY4 = nY3 + 45 # verbe
        nY5 = nY4 + 68 # adverbe
        nY6 = nY5 + 13 # autre

        nXB = nX1 + 185
        nXC = nXB + 165

        nHeight = 10

        #### 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 = "-", 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.xExport = self._addWidget('export_button', 'Button', nXC+150, nY0, 50, 12, Label = self.dUI.get('export_button', "#err"), FontDescriptor = xFDSubTitle, TextColor = 0x005500)

        #### 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, 120, 14, FontDescriptor = xFDTitle)
        self._addWidget('close_button', 'Button', nX1+130, nY1+10, 50, 14, Label = self.dUI.get('close_button', "#err"), FontDescriptor = xFDTitle, TextColor = 0x550000)

        # Radio buttons: main POS tag
        # Note: the only way to group RadioButtons is to create them successively
        self.xNA = self._addWidget('nom_adj', 'RadioButton', nX1, nY2+12, 60, nHeight, Label = self.dUI.get("nom_adj", "#err"), HelpText = ":N:A")
        self.xN = self._addWidget('nom', 'RadioButton', nX1, nY2+22, 60, nHeight, Label = self.dUI.get("nom", "#err"), HelpText = ":N")
        self.xA = self._addWidget('adj', 'RadioButton', nX1, nY2+32, 60, nHeight, Label = self.dUI.get("adj", "#err"), HelpText = ":A")
        self.xM1 = self._addWidget('M1', 'RadioButton', nX1, nY3+12, 60, nHeight, Label = self.dUI.get("M1", "#err"), HelpText = ":M1")
202
203
204
205
206
207
208
209

210
211
212
213
214


215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236

237
238
239
240




241
242
243
244
245
246
247
210
211
212
213
214
215
216

217
218
219
220


221
222
223


















224
225

226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241







-
+



-
-
+
+

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-


-
+




+
+
+
+







        self._addWidget('flexion_label', 'FixedText', nX2, nY6+11, 35, nHeight, Label = self.dUI.get('flexion', "#err"))
        self.xFlexion = self._addWidget('flexion', 'Edit', nX2+40, nY6+10, 100, nHeight)
        self._addWidget('tags_label', 'FixedText', nX2, nY6+23, 35, nHeight, Label = self.dUI.get('tags', "#err"))
        self.xTags = self._addWidget('tags', 'Edit', nX2+40, nY6+22, 100, nHeight)

        #### Generated words
        self._addWidget("gwords_section", 'FixedLine', nXB, nY1, 160, nHeight, Label = self.dUI.get("new_section", "#err"), FontDescriptor = xFDTitle)
        self.xGridModelNew = self._addGrid("list_grid_gwords", nXB, nY1+10, 160, 175, [
        self.xGridModelNew = self._addGrid("list_grid_gwords", nXB, nY1+10, 160, 255, [
            {"Title": self.dUI.get("lex_flex", "#err"), "ColumnWidth": 80},
            {"Title": self.dUI.get("lex_tags", "#err"), "ColumnWidth": 80}
        ], SelectionModel = uno.Enum("com.sun.star.view.SelectionType", "MULTI"))
        self.xAdd = self._addWidget('add_button', 'Button', nXB, nY1+190, 75, 12, Label = self.dUI.get('add_button', "#err"), FontDescriptor = xFDSubTitle, TextColor = 0x005500, Enabled = False)
        self.xDelete = self._addWidget('delete_button', 'Button', nXB+80, nY1+190, 80, 12, Label = self.dUI.get('delete_button', "#err"), FontDescriptor = xFDSubTitle, TextColor = 0x550000)
        self.xAdd = self._addWidget('add_button', 'Button', nXB, nY1+270, 75, 12, Label = self.dUI.get('add_button', "#err"), FontDescriptor = xFDSubTitle, TextColor = 0x005500, Enabled = False)
        self.xDelete = self._addWidget('delete_button', 'Button', nXB+80, nY1+270, 80, 12, Label = self.dUI.get('delete_button', "#err"), FontDescriptor = xFDSubTitle, TextColor = 0x550000)

        nY2b = nY1 + 205
        # lexicon info section
        self._addWidget("lexicon_info_section", 'FixedLine', nXB, nY2b, 160, nHeight, Label = self.dUI.get("lexicon_info_section", "#err"), FontDescriptor = xFDTitle)
        self._addWidget("added_entries_label", 'FixedText', nXB, nY2b+10, 65, nHeight, Label = self.dUI.get("added_entries_label", "#err"))
        self._addWidget("deleted_entries_label", 'FixedText', nXB, nY2b+20, 65, nHeight, Label = self.dUI.get("deleted_entries_label", "#err"))
        self._addWidget("num_of_entries_label1", 'FixedText', nXB, nY2b+30, 65, nHeight, Label = self.dUI.get("num_of_entries_label", "#err"))
        self.xNumAdded = self._addWidget("added_entries", 'FixedText', nXB+70, nY2b+10, 45, nHeight, Label = "0")
        self.xNumDeleted = self._addWidget("deleted_entries", 'FixedText', nXB+70, nY2b+20, 45, nHeight, Label = "0")
        self.xNumLex = self._addWidget("num_of_entries1", 'FixedText', nXB+70, nY2b+30, 45, nHeight, Label = "0")
        self.xSave = self._addWidget('save_button', 'Button', nXC-50, nY2b+30, 45, 12, Label = self.dUI.get('save_button', "#err"), FontDescriptor = xFDSubTitle, TextColor = 0x005500)
        # dictionary section
        self._addWidget("dictionary_section", 'FixedLine', nXB, nY2b+45, 160, nHeight, Label = self.dUI.get("dictionary_section", "#err"), FontDescriptor = xFDTitle)
        self._addWidget("save_date_label", 'FixedText', nXB, nY2b+55, 65, nHeight, Label = self.dUI.get("save_date_label", "#err"))
        self._addWidget("num_of_entries_label2", 'FixedText', nXB, nY2b+65, 65, nHeight, Label = self.dUI.get("num_of_entries_label", "#err"))
        self.xDateDic = self._addWidget("save_date", 'FixedText', nXB+70, nY2b+55, 90, nHeight, Label = "-")
        self.xNumDic = self._addWidget("num_of_entries2", 'FixedText', nXB+70, nY2b+65, 45, nHeight, Label = "0")
        self.xExport = self._addWidget('export_button', 'Button', nXC-50, nY2b+65, 45, 12, Label = self.dUI.get('export_button', "#err"), FontDescriptor = xFDSubTitle, TextColor = 0x005500)

        #### Lexicon section
        self._addWidget("lexicon_section", 'FixedLine', nXC, nY1, 200, nHeight, Label = self.dUI.get("lexicon_section", "#err"), FontDescriptor = xFDTitle)
        self.xGridModelLex = self._addGrid("list_grid_lexicon", nXC, nY1+10, 200, 270, [
        self.xGridModelLex = self._addGrid("list_grid_lexicon", nXC, nY1+10, 200, 255, [
            {"Title": self.dUI.get("lex_flex", "#err"), "ColumnWidth": 65},
            {"Title": self.dUI.get("lex_lemma", "#err"), "ColumnWidth": 50},
            {"Title": self.dUI.get("lex_tags", "#err"), "ColumnWidth": 65}
        ], SelectionModel = uno.Enum("com.sun.star.view.SelectionType", "MULTI"))
        self._addWidget("num_of_entries_label1", 'FixedText', nXC, nY1+272, 60, nHeight, Label = self.dUI.get("num_of_entries_label", "#err"), FontDescriptor = xFDSubTitle)
        self.xNumLex = self._addWidget("num_of_entries1", 'FixedText', nXC+65, nY1+272, 40, nHeight, Label = "0", FontDescriptor = xFDSubTitle)
        self.xSave = self._addWidget('save_button', 'Button', nXC+110, nY1+270, 45, 12, Label = self.dUI.get('save_button', "#err"), FontDescriptor = xFDSubTitle, TextColor = 0x005500)
        self._addWidget('close_button', 'Button', nXC+160, nY1+270, 40, 12, Label = self.dUI.get('close_button', "#err"), FontDescriptor = xFDSubTitle, TextColor = 0x550000)

        self.loadLexicon()

        # container
        self.xContainer = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialog', self.ctx)
        self.xContainer.setModel(self.xDialog)
        self.xGridControlNew = self.xContainer.getControl('list_grid_gwords')
316
317
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
310
311
312
313
314
315
316


317
318
319
320
321
322
323
324
325
326
327
328
329
330
331


332
333
334
335
336
337
338







-
-















-
-







        sJSON = xChild.getPropertyValue("personal_dic")
        if sJSON != "":
            oIBDAWG = ibdawg.IBDAWG(json.loads(sJSON))
            xGridDataModel = self.xGridModelLex.GridDataModel
            for i, sLine in enumerate(oIBDAWG.select()):
                sFlexion, sLemma, sTag = sLine.split("\t")
                xGridDataModel.addRow(i, (sFlexion, sLemma, sTag))
            self.xNumAdded.Label = "0"
            self.xNumDeleted.Label = "0"
            self.xNumLex.Label = str(i)
            self.xNumDic.Label = str(i)
            self.xDateDic.Label = oIBDAWG.sDate

    @_waitPointer
    def saveLexicon (self):
        xGridDataModel = self.xGridModelLex.GridDataModel
        lEntry = []
        for i in range(xGridDataModel.RowCount):
            lEntry.append(xGridDataModel.getRowData(i))
        oDAWG = dawg.DAWG(lEntry, "S", "fr", "Français", "Dictionnaire personnel")
        oJSON = oDAWG.getBinaryAsJSON()
        xChild = self.xSettingNode.getByName("o_fr")
        xChild.setPropertyValue("personal_dic", json.dumps(oJSON, ensure_ascii=False))
        self.xSettingNode.commitChanges()
        self.xNumAdded.Label = "0"
        self.xNumDeleted.Label = "0"
        self.xNumLex.Label = str(oJSON["nEntry"])
        self.xNumDic.Label = str(oJSON["nEntry"])
        self.xDateDic.Label = oJSON["sDate"]

    def _getRadioValue (self, *args):
        for x in args:
            if x.State:
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
485
486
487
488
489
490
491

492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510

511
512
513
514
515
516
517







-



















-







        xGridDataModelNew = self.xGridModelNew.GridDataModel
        xGridDataModelLex = self.xGridModelLex.GridDataModel
        nStart = xGridDataModelLex.RowCount
        for i in range(xGridDataModelNew.RowCount):
            sFlexion, sLemma, sTag = xGridDataModelNew.getRowData(i)
            xGridDataModelLex.addRow(nStart + i, (sFlexion, sLemma, sTag))
        self.xSave.Enabled = True
        self.xNumAdded.Label = str(int(self.xNumAdded.Label) + xGridDataModelNew.RowCount)
        self.xNumLex.Label = str(int(self.xNumLex.Label) + xGridDataModelNew.RowCount)
        self._resetWidgets()

    @_waitPointer
    def deleteSelectedEntries (self):
        # generated entries
        xGridDataModel = self.xGridModelNew.GridDataModel
        #helpers.xray(xGridDataModel)
        for i in self.xGridControlNew.getSelectedRows():
            if i < xGridDataModel.RowCount:
                xGridDataModel.removeRow(i)
        self.xGridControlNew.deselectAllRows()
        # lexicon
        xGridDataModel = self.xGridModelLex.GridDataModel
        nSelectedEntries = len(self.xGridControlLex.getSelectedRows())
        for i in self.xGridControlLex.getSelectedRows():
            if i < xGridDataModel.RowCount:
                xGridDataModel.removeRow(i)
        self.xGridControlLex.deselectAllRows()
        self.xNumDeleted.Label = str(int(self.xNumDeleted.Label) + nSelectedEntries)
        self.xNumLex.Label = str(xGridDataModel.RowCount)

    @_waitPointer
    def importDictionary (self):
        pass

    @_waitPointer

Modified gc_lang/fr/oxt/DictOptions/lxe_strings.py from [6f908f209a] to [8c03183532].

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

71
72



73
74
75
76
77
78
79
80
81
82
83
84
56
57
58
59
60
61
62






63
64
65


66
67
68
69
70
71
72
73
74
75
76
77
78
79
80







-
-
-
-
-
-


+
-
-
+
+
+












        "lex_#": "#",
        "lex_flex": "Flexions",
        "lex_lemma": "Lemmes",
        "lex_tags": "Étiquettes",

        "add_button": "Ajouter au lexique",
        "delete_button": "Supprimer la sélection",

        # Informations
        "lexicon_info_section": "Lexique",
        "added_entries_label": "Entrées ajoutées",
        "deleted_entries_label": "Entrées effacées",
        "num_of_entries_label": "Nombre d’entrées",
        "save_button": "Enregistrer",

        # Dictionary
        "dictionary_section": "Dictionnaire enregistré",
        "save_date_label": "Date d’enregistrement",
        "dictionary_section": "Dictionnaire personnel",
        "save_date_label": "Date d’enregistrement :",
        "num_of_entries_label": "Nombre d’entrées :",
        "export_button": "Exporter",

        #
        "close_button": "Fermer",
    },
    # Traduction délibérément limitée
    "en": {
        "title": "Grammalecte · Lexical editor",
        
        "close_button": "Close",
    },
}