Grammalecte  Check-in [d21c8802ec]

Overview
Comment:[tb] lexicon editor: delete selected items
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tb | multid
Files: files | file ages | folders
SHA3-256: d21c8802ec0f4c9e2291f1b0eb9075b723318db4aa6a96048600930ce791349b
User & Date: olr on 2018-03-19 18:57:36
Other Links: branch diff | manifest | tags
Context
2018-03-19
19:38
[tb] lexicon editor: conj initialization (again) check-in: 71052608f4 user: olr tags: tb, multid
18:57
[tb] lexicon editor: delete selected items check-in: d21c8802ec user: olr tags: tb, multid
12:37
[tb] store personal dictionary in file instead of preferences.js: create a file handler to simplify the mess check-in: 2d0855bb95 user: olr tags: tb, multid
Changes

Modified gc_lang/fr/tb/content/lex_editor.css from [2ca5e4943b] to [2bf7166364].

1




2
3
4
5
6
7
8
/* CSS */





/*
    Dictionary
*/ 
.dictionary {
    font-size: 18px;
    font-weight: bold;

>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
/* CSS */

button {
    font-weight: bold;
}

/*
    Dictionary
*/ 
.dictionary {
    font-size: 18px;
    font-weight: bold;

Modified gc_lang/fr/tb/content/lex_editor.js from [9022aa2b92] to [9880a2fcff].

60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
        this.lColumnWidth = lColumnWidth;
        this.xProgressBar = document.getElementById(sProgressBarId);
        this.xNumEntry = document.getElementById(sResultId);
        this.iEntryIndex = 0;
        this.lEntry = [];
        this.nEntry = 0
        this._createHeader();
        this.listen();
    }

    _createHeader () {
        let xListheadNode = createNode("listhead");
        for (let sColumn of this.lColumn) {
            xListheadNode.appendChild(createNode("listheader", { label: sColumn }));
        }







<







60
61
62
63
64
65
66

67
68
69
70
71
72
73
        this.lColumnWidth = lColumnWidth;
        this.xProgressBar = document.getElementById(sProgressBarId);
        this.xNumEntry = document.getElementById(sResultId);
        this.iEntryIndex = 0;
        this.lEntry = [];
        this.nEntry = 0
        this._createHeader();

    }

    _createHeader () {
        let xListheadNode = createNode("listhead");
        for (let sColumn of this.lColumn) {
            xListheadNode.appendChild(createNode("listheader", { label: sColumn }));
        }
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
152
153
154
155
156

157
158
159
160
161
162
163
        for (let data of lData) {
            xRowNode.appendChild(createNode("listcell", { label: data }));
        }
        this.xTable.appendChild(xRowNode);
        this.iEntryIndex += 1;
    }

    listen () {
        this.xTable.addEventListener("click", (xEvent) => { this.onTableClick(xEvent); }, false);
    }

    onTableClick (xEvent) {
        try {
            let xElem = xEvent.target;
            console.log(xElem);
            if (xElem.className) {
                if (xElem.className.startsWith(this.sNodeId+"_item_")) {
                    console.log("!");
                    this.deleteRow(xElem.value);
                }
            }
        }
        catch (e) {
            showError(e);
        }
    }

    deleteRow (iEntry) {
        this.lEntry[parseInt(iEntry)] = null;
        if (document.getElementById(this.sNodeId + "_row_" + iEntry)) {
            document.getElementById(this.sNodeId + "_row_" + iEntry).style.display = "none";
        }
        this.nEntry -= 1;

        this.showEntryNumber();
    }

    getEntries () {
        return this.lEntry.filter((e) => e !== null);
    }
}







|
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
|
<
|
>







123
124
125
126
127
128
129
130


131

















132

133

134
135
136
137
138
139
140
141
142
        for (let data of lData) {
            xRowNode.appendChild(createNode("listcell", { label: data }));
        }
        this.xTable.appendChild(xRowNode);
        this.iEntryIndex += 1;
    }

    deleteSelection () {


        for (let xItem of this.xTable.selectedItems) {

















            this.lEntry[parseInt(xItem.value)] = null;

            xItem.style.display = "none";

            this.nEntry -= 1;
        }
        this.showEntryNumber();
    }

    getEntries () {
        return this.lEntry.filter((e) => e !== null);
    }
}
208
209
210
211
212
213
214

215
216
217
218
219
220
221
        document.getElementById("tag_W").addEventListener("click", () => { this.update("W"); }, false);
        // autre
        document.getElementById("tag_X").addEventListener("click", () => { this.update("X"); }, false);
        document.getElementById("flexion").addEventListener("keyup", () => { this.update(); }, false);
        document.getElementById("tags").addEventListener("keyup", () => { this.update(); }, false);
        // ajout
        document.getElementById("add_to_lexicon").addEventListener("click", () => { this.addToLexicon(); }, false);

    },

    clear: function () {
        try {
            // nom commun
            document.getElementById("tag_N").checked = false;
            document.getElementById("nom_adj").checked = false;







>







187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
        document.getElementById("tag_W").addEventListener("click", () => { this.update("W"); }, false);
        // autre
        document.getElementById("tag_X").addEventListener("click", () => { this.update("X"); }, false);
        document.getElementById("flexion").addEventListener("keyup", () => { this.update(); }, false);
        document.getElementById("tags").addEventListener("keyup", () => { this.update(); }, false);
        // ajout
        document.getElementById("add_to_lexicon").addEventListener("click", () => { this.addToLexicon(); }, false);
        document.getElementById("delete_selection").addEventListener("click", () => { oGenWordsTable.deleteSelection(); }, false);
    },

    clear: function () {
        try {
            // nom commun
            document.getElementById("tag_N").checked = false;
            document.getElementById("nom_adj").checked = false;
459
460
461
462
463
464
465

466
467
468
469
470
471
472

    setDictData: function (nEntries, sDate) {
        document.getElementById("dic_num_entries").value = nEntries;
        document.getElementById("dic_save_date").value = sDate;
    },

    listen: function () {

        document.getElementById("save_button").addEventListener("click", () => { this.build(); }, false);
        document.getElementById("export_button").addEventListener("click", () => { this.export(); }, false);
        //document.getElementById("import_button").addEventListener("click", () => { this.import(); }, false);
    },

    build: function () {
        let xProgressNode = document.getElementById("wait_progress");







>







439
440
441
442
443
444
445
446
447
448
449
450
451
452
453

    setDictData: function (nEntries, sDate) {
        document.getElementById("dic_num_entries").value = nEntries;
        document.getElementById("dic_save_date").value = sDate;
    },

    listen: function () {
        document.getElementById("delete_button").addEventListener("click", () => { oLexiconTable.deleteSelection(); }, false);
        document.getElementById("save_button").addEventListener("click", () => { this.build(); }, false);
        document.getElementById("export_button").addEventListener("click", () => { this.export(); }, false);
        //document.getElementById("import_button").addEventListener("click", () => { this.import(); }, false);
    },

    build: function () {
        let xProgressNode = document.getElementById("wait_progress");
566
567
568
569
570
571
572

573
574
575
576
577
578
                OS.File.writeAtomic(xFilePicker.file.path, xEncodedRes, {tmpPath: "file.txt.tmp"});
             }
        });
    }
}



const oLexiconTable = new Table("lexicon_table", ["Flexions", "Lemmes", "Étiquettes"], [10, 7, 10], "progress_lexicon", "num_entries");
const oGenWordsTable = new Table("generated_words_table", ["Flexions", "Étiquettes"], [1, 1], "progress_new_words");

oBinaryDict.load();
oBinaryDict.listen();
oGenerator.listen();







>

|




547
548
549
550
551
552
553
554
555
556
557
558
559
560
                OS.File.writeAtomic(xFilePicker.file.path, xEncodedRes, {tmpPath: "file.txt.tmp"});
             }
        });
    }
}


const oGenWordsTable = new Table("generated_words_table", ["Flexions", "Étiquettes"], [1, 1], "progress_new_words");
const oLexiconTable = new Table("lexicon_table", ["Flexions", "Lemmes", "Étiquettes"], [10, 7, 10], "progress_lexicon", "num_entries");


oBinaryDict.load();
oBinaryDict.listen();
oGenerator.listen();

Modified gc_lang/fr/tb/content/lex_editor.xul from [121a38c9de] to [509f3f99a7].

134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162


163
164
165
166
167
168
169
170
171
172
173
174
175
176



177
178

179
180
181
182
183
184
185
186
187
188
189
                <textbox id="tags" class="other_textbox" value="" />
              </hbox>
            </vbox>
          </vbox>

          <vbox>
            <dialogheader title="Mots générés" description="" />
            <listbox id="generated_words_table">
              <!--
              <listhead>
                <listheader label="Flexions"/>
                <listheader label="Étiquettes"/>
              </listhead>

              <listcols>
                <listcol flex="1"/>
                <listcol flex="1"/>
              </listcols>

              <listitem>
                <listcell label="George"/>
                <listcell label="House"/>
              </listitem>
              -->
            </listbox>
            <progressmeter id="progress_new_words" value="0"/>
            <hbox>
              <button id="add_to_lexicon" label="Ajouter au lexique" />
              <button id="delete_selection" label="Effacer la sélection" />


            </hbox>
          </vbox>
        </hbox>
      </tabpanel>

      <!-- LEXICON -->
      <tabpanel orient="vertical">
        <dialogheader title="&dialogheader.lexicon.label;" description="" />
        <hbox>
          <vbox>
            <hbox>
              <label class="info_label" value="Nombre d’entrées : " />
              <label id="num_entries" class="data" value="0" />
            </hbox>



            <progressmeter id="progress_lexicon" value="0"/>
            <button id="save_button" label="Enregistrer" />        

          </vbox>

          <vbox>
            <listbox id="lexicon_table">
              <!--
              <listhead>
                <listheader label="Flexions"/>
                <listheader label="Lemmes"/>
                <listheader label="Étiquettes"/>
              </listhead>








|



















<

>
>














>
>
>

|
>



|







134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160

161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
                <textbox id="tags" class="other_textbox" value="" />
              </hbox>
            </vbox>
          </vbox>

          <vbox>
            <dialogheader title="Mots générés" description="" />
            <listbox id="generated_words_table" seltype="multiple">
              <!--
              <listhead>
                <listheader label="Flexions"/>
                <listheader label="Étiquettes"/>
              </listhead>

              <listcols>
                <listcol flex="1"/>
                <listcol flex="1"/>
              </listcols>

              <listitem>
                <listcell label="George"/>
                <listcell label="House"/>
              </listitem>
              -->
            </listbox>
            <progressmeter id="progress_new_words" value="0"/>
            <hbox>

              <button id="delete_selection" label="Effacer la sélection" />
              <spacer flex="1" />
              <button id="add_to_lexicon" label="Ajouter au lexique" />
            </hbox>
          </vbox>
        </hbox>
      </tabpanel>

      <!-- LEXICON -->
      <tabpanel orient="vertical">
        <dialogheader title="&dialogheader.lexicon.label;" description="" />
        <hbox>
          <vbox>
            <hbox>
              <label class="info_label" value="Nombre d’entrées : " />
              <label id="num_entries" class="data" value="0" />
            </hbox>
            <spacer flex="1" />
            <button id="delete_button" label="Supprimer la sélection" />
            <spacer flex="20" />
            <progressmeter id="progress_lexicon" value="0"/>
            <button id="save_button" label="Enregistrer" />

          </vbox>

          <vbox>
            <listbox id="lexicon_table" seltype="multiple">
              <!--
              <listhead>
                <listheader label="Flexions"/>
                <listheader label="Lemmes"/>
                <listheader label="Étiquettes"/>
              </listhead>