• R/O
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

OmegaT の翻訳状況(Statistics)を Excel で表示します。


Commit MetaInfo

Revision4 (tree)
Zeit2013-12-03 23:25:28
Autoryu-tang

Log Message

Fix #50102

Ändern Zusammenfassung

Diff

--- src/jp/sourceforge/users/yutang/omegat/plugin/stats2excel/Stats2Excel.java (revision 3)
+++ src/jp/sourceforge/users/yutang/omegat/plugin/stats2excel/Stats2Excel.java (revision 4)
@@ -16,12 +16,18 @@
1616
1717 package jp.sourceforge.users.yutang.omegat.plugin.stats2excel;
1818
19+import java.lang.reflect.InvocationTargetException;
20+import java.util.Comparator;
21+import java.util.ResourceBundle;
22+import org.apache.lucene.util.StringHelper;
1923 import org.omegat.core.Core;
2024 import org.omegat.core.CoreEvents;
2125 import org.omegat.core.events.IProjectEventListener.PROJECT_CHANGE_TYPE.*;
26+import org.omegat.util.Log;
2227 import static org.omegat.util.Platform.OsType.WIN32;
2328 import static org.omegat.util.Platform.OsType.WIN64;
2429 import static org.omegat.util.Platform.getOsType;
30+import org.omegat.util.StaticUtils;
2531
2632 /**
2733 * open Statistics with Excel from standard Tools menu
@@ -30,18 +36,28 @@
3036 */
3137 public class Stats2Excel {
3238
33- public static void loadPlugins() {
39+ private static String __VERSION_KEY = "version";
40+
41+ public static void loadPlugins() throws InvocationTargetException {
3442 try {
35- if (isWindows()) {
36- // Not initialize in console mode.
37- CoreEvents.registerApplicationEventListener(StatsController.getInstance());
38- } else {
39- Core.pluginLoadingError("Plugin Stats2Excel cannot be loaded "
40- + "because only Windows platform is supported");
43+ final String OMT_VERSION = ResourceBundle.getBundle(
44+ "org/omegat/Version").getString(__VERSION_KEY);
45+ if (! isAvailableOmTVersion(OMT_VERSION)) {
46+ throw new RuntimeException(L10n.getLoadingErrorVersionTooOld());
4147 }
48+
49+ if (! isWindows()) {
50+ throw new RuntimeException(L10n.getLoadingErrorWrongPlatform());
51+ }
52+
53+ // Not initialize in console mode.
54+ CoreEvents.registerApplicationEventListener(
55+ StatsController.getInstance());
4256 } catch (Throwable ex) {
43- Core.pluginLoadingError("Plugin Stats2Excel cannot be loaded "
44- + "because this version of OmegaT is not supported");
57+ String msg = StaticUtils.format(L10n.getLoadingErrorFormat(),
58+ ex.getMessage());
59+ Log.logErrorRB(msg);
60+ Core.pluginLoadingError(msg);
4561 }
4662 }
4763
@@ -58,4 +74,9 @@
5874 return false;
5975 }
6076
77+ private static boolean isAvailableOmTVersion(String version) {
78+ Comparator<String> comp = StringHelper.getVersionComparator();
79+ return (comp.compare(version, "3.0.7") >= 0);
80+ }
81+
6182 }
\ No newline at end of file
--- src/jp/sourceforge/users/yutang/omegat/plugin/stats2excel/VersionInfo.java (revision 3)
+++ src/jp/sourceforge/users/yutang/omegat/plugin/stats2excel/VersionInfo.java (revision 4)
@@ -26,7 +26,7 @@
2626
2727 private static final String APP_NAME = "Stats2Excel";
2828 private static final String APP_VERSION = "0.1";
29- private static final String APP_BUILD = "20131201";
29+ private static final String APP_BUILD = "20131203";
3030 private static final String APP_AUTHOR = "Yu Tang";
3131
3232 public static void main(String[] args) {
--- src/jp/sourceforge/users/yutang/omegat/plugin/stats2excel/L10n.java (revision 3)
+++ src/jp/sourceforge/users/yutang/omegat/plugin/stats2excel/L10n.java (revision 4)
@@ -42,4 +42,18 @@
4242 return bundle.getString("S2E_EXCEL_WINDOW_TITLE");
4343 }
4444
45+ // Error
46+
47+ public static String getLoadingErrorFormat() {
48+ return bundle.getString("S2E_LOADING_ERROR_FORMAT");
49+ }
50+
51+ public static String getLoadingErrorVersionTooOld() {
52+ return bundle.getString("S2E_LOADING_ERROR_VERSION_TOO_OLD");
53+ }
54+
55+ public static String getLoadingErrorWrongPlatform() {
56+ return bundle.getString("S2E_LOADING_ERROR_WRONG_PLATFORM");
57+ }
58+
4559 }
--- src/jp/sourceforge/users/yutang/omegat/plugin/stats2excel/SplashStatisticsWindow.java (revision 3)
+++ src/jp/sourceforge/users/yutang/omegat/plugin/stats2excel/SplashStatisticsWindow.java (revision 4)
@@ -88,28 +88,27 @@
8888 }
8989
9090 service = Executors.newSingleThreadScheduledExecutor();
91+ service.scheduleWithFixedDelay(new Runnable() {
9192
92- service.scheduleWithFixedDelay(new Runnable() {
93-
94- @Override
95- public void run() {
96- try {
97- if (ExcelModel.activate()) {
98- service.shutdown();
99- service = null;
100- }
101- } catch (IOException ex) {
102- Log.log(ex);
103- setText(ex.getLocalizedMessage());
93+ @Override
94+ public void run() {
95+ try {
96+ if (ExcelModel.activate()) {
10497 service.shutdown();
105- service =null;
106- } catch (InterruptedException ex) {
107- Log.log(ex);
108- setText(ex.getLocalizedMessage());
109- service.shutdown();
110- service =null;
98+ service = null;
11199 }
100+ } catch (IOException ex) {
101+ Log.log(ex);
102+ setText(ex.getLocalizedMessage());
103+ service.shutdown();
104+ service =null;
105+ } catch (InterruptedException ex) {
106+ Log.log(ex);
107+ setText(ex.getLocalizedMessage());
108+ service.shutdown();
109+ service =null;
112110 }
111+ }
113112 }, 0, 500, TimeUnit.MILLISECONDS);
114113 }
115114