Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.i18n.app / org.gvsig.i18n.app.mainplugin / src / main / java / org / gvsig / i18n / extension / ConsolideTranslationsExtension.java @ 41284

History | View | Annotate | Download (3.19 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA 02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/*
25
 * AUTHORS (In addition to CIT):
26
 * 2008 {DiSiD Technologies}  {New extension for installation and update of text translations}
27
 */
28
package org.gvsig.i18n.extension;
29

    
30
import javax.swing.JOptionPane;
31
import org.gvsig.andami.PluginServices;
32
import org.gvsig.andami.plugins.Extension;
33
import org.gvsig.andami.ui.mdiFrame.MainFrame;
34
import org.gvsig.i18n.impl.TranslationsConsolider;
35
import org.slf4j.Logger;
36
import org.slf4j.LoggerFactory;
37

    
38
/**
39
 * Texts localization management extension.
40
 *
41
 * @author <a href="mailto:dcervera@disid.com">David Cervera</a>
42
 */
43
public class ConsolideTranslationsExtension extends Extension {
44

    
45
    private static final Logger logger = LoggerFactory.getLogger(ConsolideTranslationsExtension.class);
46

    
47
    private boolean executing = false;
48

    
49
    public synchronized void execute(String actionCommand) {
50
        final MainFrame main = PluginServices.getMainFrame();
51

    
52
        if ( "tools-devel-consolidate-translations".equalsIgnoreCase(actionCommand) ) {
53
            if ( this.executing ) {
54
                main.messageDialog("Process is running.", "Warning", JOptionPane.INFORMATION_MESSAGE);
55
                return;
56
            }
57
            this.executing = true;
58
            main.refreshControls();
59
            Thread process = new Thread(new Runnable() {
60
                public void run() {
61
                    try {
62
                        TranslationsConsolider consolider = new TranslationsConsolider();
63
                        consolider.consolide();
64
                        main.messageDialog("Consolidation of translations terminated.", "Information", JOptionPane.INFORMATION_MESSAGE);
65
                    } catch(Exception ex) {
66
                        logger.warn("There was errors consolidating translations.",ex);
67
                        main.messageDialog("There was errors consolidating translations.", "Warning", JOptionPane.WARNING_MESSAGE);
68
                    } finally {
69
                        executing = false;
70
                        main.refreshControls();
71
                    }
72
                }
73
            });
74
            process.start();
75
        }
76
    }
77

    
78
    public void initialize() {
79
        // Do nothing
80
    }
81

    
82
    public boolean isEnabled() {
83
        return ! this.executing;
84
    }
85

    
86
    public boolean isVisible() {
87
        return true;
88
    }
89
}