PageRenderTime 349ms CodeModel.GetById 101ms app.highlight 153ms RepoModel.GetById 88ms app.codeStats 0ms

/src/mpv5/ui/frames/MPBabelFish.java

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 552 lines | 438 code | 73 blank | 41 comment | 17 complexity | 055e4b02f79731caaa723148af2a19a4 MD5 | raw file
  1/*
  2 *  This file is part of YaBS.
  3 *
  4 *      YaBS is free software: you can redistribute it and/or modify
  5 *      it under the terms of the GNU General Public License as published by
  6 *      the Free Software Foundation, either version 3 of the License, or
  7 *      (at your option) any later version.
  8 *
  9 *      YaBS is distributed in the hope that it will be useful,
 10 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12 *      GNU General Public License for more details.
 13 *
 14 *      You should have received a copy of the GNU General Public License
 15 *      along with YaBS.  If not, see <http://www.gnu.org/licenses/>.
 16 */
 17/*
 18 * MPBabelFish.java
 19 *
 20 * Created on 01.02.2009, 17:33:56
 21 */
 22package mpv5.ui.frames;
 23
 24import javax.swing.DefaultComboBoxModel;
 25import mpv5.db.common.NodataFoundException;
 26import mpv5.globals.Headers;
 27import mpv5.globals.Messages;
 28import mpv5.i18n.LanguageManager;
 29import mpv5.ui.dialogs.DialogForFile;
 30
 31import java.awt.Cursor;
 32import java.io.File;
 33import javax.swing.JTextField;
 34import javax.swing.SwingWorker;
 35import javax.swing.table.DefaultTableModel;
 36import mpv5.db.common.Context;
 37import mpv5.db.common.QueryHandler;
 38import mpv5.db.objects.User;
 39import mpv5.globals.Constants;
 40import mpv5.globals.GlobalSettings;
 41import mpv5.logging.Log;
 42import mpv5.ui.dialogs.Popup;
 43import mpv5.ui.dialogs.PropertyDialog;
 44import mpv5.ui.misc.Position;
 45import mpv5.usermanagement.MPSecurityManager;
 46
 47import mpv5.utils.models.MPComboBoxModelItem;
 48import mpv5.utils.models.MPTableModel;
 49import mpv5.utils.arrays.ArrayUtilities;
 50import mpv5.utils.files.FileReaderWriter;
 51import mpv5.utils.tables.ExcelAdapter;
 52import mpv5.utils.text.RandomText;
 53import mpv5.utils.ui.TextFieldUtils;
 54
 55/**
 56 *
 57 *  
 58 */
 59public class MPBabelFish extends javax.swing.JFrame {
 60
 61    private String url;
 62
 63    /** Creates new form MPBabelFish */
 64    public MPBabelFish() {
 65        initComponents();
 66        new ExcelAdapter(data);
 67        setToolBar();
 68        new Position(this);
 69        setAlwaysOnTop(false);
 70        setVisible(rootPaneCheckingEnabled);
 71        setLanguageSelection();
 72
 73//        Translate.setHttpReferrer(Constants.VERSION);
 74
 75    }
 76
 77    private void setLanguage() {
 78
 79        setCursor(new Cursor(Cursor.WAIT_CURSOR));
 80        data.setModel(new MPTableModel(
 81                new Class[]{String.class, String.class, String.class},
 82                new boolean[]{false, true, true},
 83                LanguageManager.getEditorModel(((MPComboBoxModelItem) languages.getSelectedItem()).getId()),
 84                Headers.BABELFISH.getValue()));
 85        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
 86    }
 87
 88    private void setLanguageSelection() {
 89        languages.setModel(LanguageManager.getLanguagesAsComboBoxModel());
 90        languages.setSelectedIndex(MPComboBoxModelItem.getItemID(mpv5.db.objects.User.getCurrentUser().__getLanguage(),
 91                languages.getModel()));
 92
 93        setLanguage();
 94    }
 95
 96    /** This method is called from within the constructor to
 97     * initialize the form.
 98     * WARNING: Do NOT modify this code. The content of this method is
 99     * always regenerated by the Form Editor.
100     */
101    @SuppressWarnings("unchecked")
102    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
103    private void initComponents() {
104
105        jPanel1 = new javax.swing.JPanel();
106        jLabel1 = new javax.swing.JLabel();
107        jScrollPane1 = new javax.swing.JScrollPane();
108        data = new javax.swing.JTable();
109        jLabel2 = new javax.swing.JLabel();
110        languages = new javax.swing.JComboBox();
111        langName = new mpv5.ui.beans.LabeledTextField();
112        jLabel7 = new javax.swing.JLabel();
113        GooogleTranslator = new javax.swing.JToolBar();
114        jLabel5 = new javax.swing.JLabel();
115        webserviceurl = new javax.swing.JTextField();
116        jLabel3 = new javax.swing.JLabel();
117        from = new javax.swing.JComboBox();
118        jLabel4 = new javax.swing.JLabel();
119        to = new javax.swing.JComboBox();
120        translate = new javax.swing.JButton();
121        progress = new javax.swing.JProgressBar();
122        jMenuBar1 = new javax.swing.JMenuBar();
123        jMenu1 = new javax.swing.JMenu();
124        jMenuItem4 = new javax.swing.JMenuItem();
125        jMenuItem2 = new javax.swing.JMenuItem();
126        jMenuItem1 = new javax.swing.JMenuItem();
127        jMenuItem3 = new javax.swing.JMenuItem();
128
129        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
130        java.util.ResourceBundle bundle = mpv5.i18n.LanguageManager.getBundle(); // NOI18N
131        setTitle(bundle.getString("MPBabelFish.title_1")); // NOI18N
132        setAlwaysOnTop(true);
133        setName("Form"); // NOI18N
134
135        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("MPBabelFish.jPanel1.border.title_1"))); // NOI18N
136        jPanel1.setName("jPanel1"); // NOI18N
137
138        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/babelfish.png"))); // NOI18N
139        jLabel1.setName("jLabel1"); // NOI18N
140
141        jScrollPane1.setName("jScrollPane1"); // NOI18N
142
143        data.setModel(new javax.swing.table.DefaultTableModel(
144            new Object [][] {
145                {},
146                {},
147                {},
148                {}
149            },
150            new String [] {
151
152            }
153        ));
154        data.setAutoCreateRowSorter(true);
155        data.setColumnSelectionAllowed(true);
156        data.setDoubleBuffered(true);
157        data.setDragEnabled(true);
158        data.setName("data"); // NOI18N
159        data.setSurrendersFocusOnKeystroke(true);
160        jScrollPane1.setViewportView(data);
161        data.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
162
163        jLabel2.setText(bundle.getString("MPBabelFish.jLabel2.text_1")); // NOI18N
164        jLabel2.setName("jLabel2"); // NOI18N
165
166        languages.setName("languages"); // NOI18N
167        languages.addMouseListener(new java.awt.event.MouseAdapter() {
168            public void mouseClicked(java.awt.event.MouseEvent evt) {
169                languagesMouseClicked(evt);
170            }
171            public void mouseExited(java.awt.event.MouseEvent evt) {
172                languagesMouseExited(evt);
173            }
174        });
175        languages.addActionListener(new java.awt.event.ActionListener() {
176            public void actionPerformed(java.awt.event.ActionEvent evt) {
177                languagesActionPerformed(evt);
178            }
179        });
180
181        langName.set_Label(bundle.getString("MPBabelFish.langName._Label")); // NOI18N
182        langName.setName("langName"); // NOI18N
183
184        jLabel7.setText(bundle.getString("MPBabelFish.jLabel7.text")); // NOI18N
185        jLabel7.setName("jLabel7"); // NOI18N
186
187        GooogleTranslator.setRollover(true);
188        GooogleTranslator.setName("GooogleTranslator"); // NOI18N
189
190        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
191        jLabel5.setText(bundle.getString("MPBabelFish.jLabel5.text")); // NOI18N
192        jLabel5.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 0, 1, 5));
193        jLabel5.setEnabled(false);
194        jLabel5.setName("jLabel5"); // NOI18N
195        GooogleTranslator.add(jLabel5);
196
197        webserviceurl.setText(bundle.getString("MPBabelFish.webserviceurl.text")); // NOI18N
198        webserviceurl.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 5, 1, 5));
199        webserviceurl.setEnabled(false);
200        webserviceurl.setName("webserviceurl"); // NOI18N
201        GooogleTranslator.add(webserviceurl);
202
203        jLabel3.setText(bundle.getString("MPBabelFish.jLabel3.text")); // NOI18N
204        jLabel3.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 5, 1, 5));
205        jLabel3.setEnabled(false);
206        jLabel3.setName("jLabel3"); // NOI18N
207        GooogleTranslator.add(jLabel3);
208
209        from.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 5, 1, 5));
210        from.setEnabled(false);
211        from.setName("from"); // NOI18N
212        GooogleTranslator.add(from);
213
214        jLabel4.setText(bundle.getString("MPBabelFish.jLabel4.text")); // NOI18N
215        jLabel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 5, 1, 5));
216        jLabel4.setEnabled(false);
217        jLabel4.setName("jLabel4"); // NOI18N
218        GooogleTranslator.add(jLabel4);
219
220        to.setAutoscrolls(true);
221        to.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 5, 1, 5));
222        to.setEnabled(false);
223        to.setName("to"); // NOI18N
224        GooogleTranslator.add(to);
225
226        translate.setText(bundle.getString("MPBabelFish.translate.text")); // NOI18N
227        translate.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 5, 1, 5));
228        translate.setEnabled(false);
229        translate.setFocusable(false);
230        translate.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
231        translate.setName("translate"); // NOI18N
232        translate.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
233        translate.addActionListener(new java.awt.event.ActionListener() {
234            public void actionPerformed(java.awt.event.ActionEvent evt) {
235                translateActionPerformed(evt);
236            }
237        });
238        GooogleTranslator.add(translate);
239
240        progress.setName("progress"); // NOI18N
241
242        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
243        jPanel1.setLayout(jPanel1Layout);
244        jPanel1Layout.setHorizontalGroup(
245            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
246            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
247                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
248                    .addComponent(jLabel2)
249                    .addComponent(languages, javax.swing.GroupLayout.PREFERRED_SIZE, 195, javax.swing.GroupLayout.PREFERRED_SIZE))
250                .addGap(36, 36, 36)
251                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
252                    .addGroup(jPanel1Layout.createSequentialGroup()
253                        .addComponent(langName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
254                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
255                        .addComponent(progress, javax.swing.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE))
256                    .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, 446, Short.MAX_VALUE))
257                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
258                .addComponent(jLabel1)
259                .addContainerGap())
260            .addComponent(GooogleTranslator, javax.swing.GroupLayout.DEFAULT_SIZE, 725, Short.MAX_VALUE)
261            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 725, Short.MAX_VALUE)
262        );
263        jPanel1Layout.setVerticalGroup(
264            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
265            .addGroup(jPanel1Layout.createSequentialGroup()
266                .addContainerGap()
267                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
268                    .addComponent(jLabel2)
269                    .addComponent(jLabel7))
270                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
271                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER, false)
272                    .addComponent(languages, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
273                    .addComponent(langName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
274                    .addComponent(progress, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
275                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
276                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE)
277                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
278                .addComponent(GooogleTranslator, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
279            .addGroup(jPanel1Layout.createSequentialGroup()
280                .addComponent(jLabel1)
281                .addContainerGap(307, Short.MAX_VALUE))
282        );
283
284        jMenuBar1.setName("jMenuBar1"); // NOI18N
285
286        jMenu1.setText(bundle.getString("MPBabelFish.jMenu1.text_1")); // NOI18N
287        jMenu1.setName("jMenu1"); // NOI18N
288
289        jMenuItem4.setText(bundle.getString("MPBabelFish.jMenuItem4.text")); // NOI18N
290        jMenuItem4.setName("jMenuItem4"); // NOI18N
291        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
292            public void actionPerformed(java.awt.event.ActionEvent evt) {
293                jMenuItem4ActionPerformed(evt);
294            }
295        });
296        jMenu1.add(jMenuItem4);
297
298        jMenuItem2.setText(bundle.getString("MPBabelFish.jMenuItem2.text_1")); // NOI18N
299        jMenuItem2.setName("jMenuItem2"); // NOI18N
300        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
301            public void actionPerformed(java.awt.event.ActionEvent evt) {
302                jMenuItem2ActionPerformed(evt);
303            }
304        });
305        jMenu1.add(jMenuItem2);
306
307        jMenuItem1.setText(bundle.getString("MPBabelFish.jMenuItem1.text_1")); // NOI18N
308        jMenuItem1.setName("jMenuItem1"); // NOI18N
309        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
310            public void actionPerformed(java.awt.event.ActionEvent evt) {
311                jMenuItem1ActionPerformed(evt);
312            }
313        });
314        jMenu1.add(jMenuItem1);
315
316        jMenuItem3.setText(bundle.getString("MPBabelFish.jMenuItem3.text_1")); // NOI18N
317        jMenuItem3.setName("jMenuItem3"); // NOI18N
318        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
319            public void actionPerformed(java.awt.event.ActionEvent evt) {
320                jMenuItem3ActionPerformed(evt);
321            }
322        });
323        jMenu1.add(jMenuItem3);
324
325        jMenuBar1.add(jMenu1);
326
327        setJMenuBar(jMenuBar1);
328
329        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
330        getContentPane().setLayout(layout);
331        layout.setHorizontalGroup(
332            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
333            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
334        );
335        layout.setVerticalGroup(
336            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
337            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
338        );
339
340        pack();
341    }// </editor-fold>//GEN-END:initComponents
342
343    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
344
345        if (MPSecurityManager.checkAdminAccess()
346                && QueryHandler.instanceOf().clone(Context.getLanguage()).checkUniqueness("longname", new JTextField[]{langName.getTextField()})) {
347            if (langName.hasText()) {
348                Runnable runnable = new Runnable() {
349
350                    public void run() {
351                        try {
352                            setCursor(new Cursor(Cursor.WAIT_CURSOR));
353                            LanguageManager.importLanguage(langName.get_Text(), ArrayUtilities.tableModelToFile(data, new int[]{0, 2}, "=", RandomText.getText() + "language", "yabs"));
354                            setLanguageSelection();
355                        } catch (Exception e) {
356                            Log.Debug(e);
357                        } finally {
358                            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
359                        }
360                    }
361                };
362                new Thread(runnable).start();
363            } else {
364                TextFieldUtils.blinkerRed(langName.getTextField());
365            }
366        }
367    }//GEN-LAST:event_jMenuItem2ActionPerformed
368
369    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
370
371        DialogForFile dialog = new DialogForFile(DialogForFile.FILES_ONLY);
372//        MPTableModel mpdel = DataModelUtils.getModelCopy(data);
373        dialog.saveFile(ArrayUtilities.tableModelToFile(data, new int[]{0, 1}, "=", String.valueOf(languages.getSelectedItem()), "yabs"));
374//        data.setModel(mpdel);
375//        setLanguageSelection();
376    }//GEN-LAST:event_jMenuItem1ActionPerformed
377
378    private void translateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_translateActionPerformed
379        new Job(this).execute();
380    }//GEN-LAST:event_translateActionPerformed
381
382    private void languagesMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_languagesMouseExited
383    }//GEN-LAST:event_languagesMouseExited
384
385    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
386        if (MPSecurityManager.checkAdminAccess()) {
387            if (Popup.Y_N_dialog(Messages.REALLY_WIPE + ": " + ((MPComboBoxModelItem) languages.getSelectedItem()).getValue())) {
388                try {
389                    LanguageManager.removeLanguage(((MPComboBoxModelItem) languages.getSelectedItem()).getId());
390                } catch (NodataFoundException ex) {
391                    Log.Debug(this, ex);
392                }
393            }
394        }
395
396        setLanguageSelection();
397    }//GEN-LAST:event_jMenuItem3ActionPerformed
398
399    private void languagesMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_languagesMouseClicked
400    }//GEN-LAST:event_languagesMouseClicked
401
402    private void languagesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_languagesActionPerformed
403        setLanguage();
404    }//GEN-LAST:event_languagesActionPerformed
405
406    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
407
408        DialogForFile d = new DialogForFile(DialogForFile.FILES_ONLY);
409        if (d.chooseFile()) {
410            new Job3(this, d.getFile()).execute();
411        }
412    }//GEN-LAST:event_jMenuItem4ActionPerformed
413
414    // Variables declaration - do not modify//GEN-BEGIN:variables
415    private javax.swing.JToolBar GooogleTranslator;
416    private javax.swing.JTable data;
417    private javax.swing.JComboBox from;
418    private javax.swing.JLabel jLabel1;
419    private javax.swing.JLabel jLabel2;
420    private javax.swing.JLabel jLabel3;
421    private javax.swing.JLabel jLabel4;
422    private javax.swing.JLabel jLabel5;
423    private javax.swing.JLabel jLabel7;
424    private javax.swing.JMenu jMenu1;
425    private javax.swing.JMenuBar jMenuBar1;
426    private javax.swing.JMenuItem jMenuItem1;
427    private javax.swing.JMenuItem jMenuItem2;
428    private javax.swing.JMenuItem jMenuItem3;
429    private javax.swing.JMenuItem jMenuItem4;
430    private javax.swing.JPanel jPanel1;
431    private javax.swing.JScrollPane jScrollPane1;
432    private mpv5.ui.beans.LabeledTextField langName;
433    private javax.swing.JComboBox languages;
434    private javax.swing.JProgressBar progress;
435    private javax.swing.JComboBox to;
436    private javax.swing.JButton translate;
437    private javax.swing.JTextField webserviceurl;
438    // End of variables declaration//GEN-END:variables
439
440    private void setToolBar() {
441//        from.setModel(new DefaultComboBoxModel(Language.values()));
442//        to.setModel(new DefaultComboBoxModel(Language.values()));
443    }
444
445    class Job extends SwingWorker<Object, Object> {
446
447        private MPBabelFish parent;
448
449        private Job(MPBabelFish aThis) {
450            this.parent = aThis;
451        }
452
453        @Override
454        public Object doInBackground() {
455            parent.setCursor(new Cursor(Cursor.WAIT_CURSOR));
456            String[] dat = ArrayUtilities.SmallObjectToStringArray(ArrayUtilities.getColumnAsArray(data, 1));
457            String[] translated = new String[dat.length];
458            mpv5.YabsViewProxy.instance().setProgressMaximumValue(dat.length);
459            progress.setStringPainted(true);
460            progress.setMaximum(dat.length);
461            for (int i = 0; i < dat.length; i++) {
462
463                String string = dat[i];
464                try {
465                    if (string != null && string.length() > 0) {
466                        Log.Debug(this, "Translating: " + string);
467//                        translated[i] = Translate.execute(string, (Language) from.getSelectedItem(), (Language) to.getSelectedItem());
468                        mpv5.YabsViewProxy.instance().setProgressValue(i + 1);
469                        progress.setValue(i + 1);
470                    } else {
471                        translated[i] = "";
472                        mpv5.YabsViewProxy.instance().setProgressValue(i + 1);
473                        progress.setValue(i + 1);
474                    }
475                } catch (Exception ex) {
476                    Log.Debug(this, ex.getMessage());
477                }
478            }
479            ArrayUtilities.replaceColumn(data, 2, translated);
480            return null;
481        }
482
483        @Override
484        public void done() {
485            parent.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
486            mpv5.YabsViewProxy.instance().setProgressReset();
487            progress.setValue(0);
488            Popup.notice(Messages.DONE);
489        }
490    }
491
492    class Job3 extends SwingWorker<Object, Object> {
493
494        private MPBabelFish parent;
495        private File f;
496
497        private Job3(MPBabelFish aThis, File f) {
498            this.parent = aThis;
499            this.f = f;
500        }
501
502        @Override
503        public Object doInBackground() {
504            parent.setCursor(new Cursor(Cursor.WAIT_CURSOR));
505
506            String[] originallanguage = ArrayUtilities.SmallObjectToStringArray(ArrayUtilities.getColumnAsArray(data, 1));
507            String[] components = ArrayUtilities.SmallObjectToStringArray(ArrayUtilities.getColumnAsArray(data, 0));
508
509            FileReaderWriter fr = new FileReaderWriter(f, "UTF8");
510            String[] imported = fr.readLinesWCharset();
511
512            mpv5.YabsViewProxy.instance().setProgressMaximumValue(imported.length);
513            progress.setStringPainted(true);
514            progress.setMaximum(imported.length);
515            for (int i = 0; i < originallanguage.length; i++) {
516                String component = components[i];
517                try {
518                    for (int j = 0; j < imported.length; j++) {
519                        String string = imported[j];
520                        if (string.split("=").length == 2) {
521                            if (string.split("=")[0].equals(component)) {
522                                originallanguage[i] = string.split("=")[1];
523                                mpv5.YabsViewProxy.instance().setProgressValue(i + 1);
524                                progress.setValue(i + 1);
525                            }
526                        }
527                    }
528                } catch (Exception ex) {
529                    Log.Debug(this,
530                            "\n'I refuse to prove that I exist', says God, \n"
531                            + "'for proof denies faith, and without faith I am nothing'. \n"
532                            + "'But,' says man, 'The Babel fish is a dead giveaway, isn't it? \n"
533                            + "It could not have evolved by chance. \n"
534                            + "It proves you exist, and so therefore, by your own arguments, you don't.\n"
535                            + "The Hitchhiker's Guide to the Galaxy: Babelfish\n");
536                    Log.Debug(this, ex);
537                }
538            }
539            ArrayUtilities.replaceColumn(data, 2, originallanguage);
540            return null;
541        }
542
543        @Override
544        public void done() {
545            ((MPTableModel)data.getModel()).setCanEdits(false, true, true);
546            parent.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
547            mpv5.YabsViewProxy.instance().setProgressReset();
548            progress.setValue(0);
549            Popup.notice(Messages.DONE);
550        }
551    }
552}