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 | 40557 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40557 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | *
|
||
6 | 40435 | jjdelcerro | * This program is free software; you can redistribute it and/or
|
7 | * modify it under the terms of the GNU General Public License
|
||
8 | 40557 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * of the License, or (at your option) any later version.
|
10 | 40557 | jjdelcerro | *
|
11 | 40435 | jjdelcerro | * This program is distributed in the hope that it will be useful,
|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | 41284 | jjdelcerro | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 | 40435 | jjdelcerro | * GNU General Public License for more details.
|
15 | 40557 | jjdelcerro | *
|
16 | 40435 | jjdelcerro | * 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 | 40557 | jjdelcerro | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 | 41284 | jjdelcerro | * MA 02110-1301, USA.
|
20 | 40557 | jjdelcerro | *
|
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 | 40435 | jjdelcerro | */
|
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 | 41284 | jjdelcerro | import javax.swing.JOptionPane; |
31 | import org.gvsig.andami.PluginServices; |
||
32 | 40435 | jjdelcerro | import org.gvsig.andami.plugins.Extension; |
33 | 41284 | jjdelcerro | 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 | 40435 | jjdelcerro | |
38 | /**
|
||
39 | * Texts localization management extension.
|
||
40 | 41284 | jjdelcerro | *
|
41 | 40435 | jjdelcerro | * @author <a href="mailto:dcervera@disid.com">David Cervera</a>
|
42 | */
|
||
43 | 41284 | jjdelcerro | public class ConsolideTranslationsExtension extends Extension { |
44 | 40435 | jjdelcerro | |
45 | 41284 | jjdelcerro | 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 | 40435 | jjdelcerro | } |
77 | |||
78 | public void initialize() { |
||
79 | 41284 | jjdelcerro | // Do nothing
|
80 | 40435 | jjdelcerro | } |
81 | |||
82 | public boolean isEnabled() { |
||
83 | 41284 | jjdelcerro | return ! this.executing; |
84 | 40435 | jjdelcerro | } |
85 | |||
86 | public boolean isVisible() { |
||
87 | 41284 | jjdelcerro | return true; |
88 | 40435 | jjdelcerro | } |
89 | 41284 | jjdelcerro | } |