• 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 の背景に画像を表示します。


Commit MetaInfo

Revision50 (tree)
Time2014-05-23 01:52:43
Authoryu-tang

Log Message

設定ファイルで文字列による指定になっている箇所を Enum 値による指定に変更(Parts と Type)

Change Summary

Incremental Difference

--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/MoeConfig.java (revision 49)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/MoeConfig.java (revision 50)
@@ -28,11 +28,14 @@
2828 import java.util.ArrayList;
2929 import java.util.Collections;
3030 import java.util.Comparator;
31+import java.util.HashMap;
3132 import java.util.List;
3233 import java.util.Map;
3334 import java.util.Set;
3435 import java.util.TreeSet;
36+import jp.sourceforge.users.yutang.omegat.plugin.moenizer.MoeUI.Parts;
3537 import jp.sourceforge.users.yutang.omegat.plugin.moenizer.effect.Effect;
38+import jp.sourceforge.users.yutang.omegat.plugin.moenizer.effect.Effect.Type;
3639 import org.omegat.util.Log;
3740
3841 /**
@@ -63,12 +66,29 @@
6366 public MoeConfig(File file) throws IOException {
6467 this.file = file;
6568 if (file.isFile()) {
66- //@@TODO setBinding で文字列の指定を追い出す
67- config = new ConfigSlurper().parse(file.toURI().toURL());
69+ config = createBindedConfigSlurper().parse(file.toURI().toURL());
6870 addAll(sortedConfigs, config);
6971 }
7072 }
7173
74+ private ConfigSlurper createBindedConfigSlurper() {
75+ ConfigSlurper configSlurper = new ConfigSlurper();
76+ Map map = new HashMap<String, Parts>();
77+
78+ // MoeUI.Parts enum
79+ for (Parts part: Parts.values()) {
80+ map.put(part.name(), part);
81+ }
82+
83+ // Effect.Type enum
84+ for (Type type: Type.values()) {
85+ map.put(type.name(), type);
86+ }
87+
88+ configSlurper.setBinding(map);
89+ return configSlurper;
90+ }
91+
7292 public Object get(String key) {
7393 if (config != null) {
7494 Map flatten = config.flatten();
@@ -150,7 +170,7 @@
150170 }
151171
152172 ConfigObject effect = new ConfigObject();
153- effect.put("type", Effect.Type.BasicEffect.name());
173+ effect.put("type", Effect.Type.BasicEffect);
154174 effect.put("image", image);
155175
156176 List<ConfigObject> effects = new ArrayList<ConfigObject>(1);
--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/ThemeChanger.java (revision 49)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/ThemeChanger.java (revision 50)
@@ -41,6 +41,7 @@
4141
4242 // check constraints
4343 //@@TODO 整合性チェック。たとえば、mainWindow 対象の処理が複数ある、など
44+ //@@TODO MainWindow の透過除外パーツに、後続指定のペインを含める
4445 }
4546
4647 public void apply() {
@@ -48,7 +49,7 @@
4849 if (theme == null || !theme.containsKey("effects")) { //@@TODO literal to const
4950 return;
5051 }
51-
52+
5253 // get effect list (ArrayList)
5354 List<ConfigObject> effects = (List<ConfigObject>) theme.get("effects"); //@@TODO literal to const
5455 if (effects.isEmpty()) {
@@ -57,9 +58,10 @@
5758
5859 // apply effects
5960 for (Map conf: effects) {
60- String type = (String) conf.get("type");
61+
6162 try {
62- IEffect effect = Effect.create(Effect.Type.valueOf(type), conf);
63+ Effect.Type type = (Effect.Type) conf.get("type");
64+ IEffect effect = Effect.create(type, conf);
6365 effect.invoke(model);
6466 } catch (Exception ex) {
6567 ex.printStackTrace();
--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/effect/BasicEffect.java (revision 49)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/effect/BasicEffect.java (revision 50)
@@ -43,17 +43,11 @@
4343 private Parts target = Parts.MainWindow;
4444 private float opacity = 0.5f;
4545 private String image = "";
46- private List<String> exclude = new ArrayList<String>();
46+ private List<Parts> exclude = new ArrayList<Parts>();
4747
4848 public BasicEffect(Map config) {
4949 if (config.containsKey(KEY_TARGET)) {
50- //@@TODO 設定自体を Enum で受け取れるように
51- String targetName = (String) config.get(KEY_TARGET);
52- try {
53- target = Parts.valueOf(targetName);
54- } catch (IllegalArgumentException ex) {
55- Log.log("warning: target name '" + targetName + "' is not found in Parts enum.");
56- }
50+ target = (Parts) config.get(KEY_TARGET);
5751 }
5852
5953 if (config.containsKey(KEY_OPACITY)) {
@@ -65,7 +59,7 @@
6559 }
6660
6761 if (config.containsKey(KEY_EXCLUDE)) {
68- exclude = (List<String>) config.get(KEY_EXCLUDE);
62+ exclude = (List<Parts>) config.get(KEY_EXCLUDE);
6963 }
7064 }
7165
@@ -77,7 +71,7 @@
7771
7872 EnumSet<Parts> excludeParts = EnumSet.noneOf(Parts.class);
7973 for (Parts part: EnumSet.allOf(Parts.class)) {
80- if (exclude.contains(part.name())) {
74+ if (exclude.contains(part)) {
8175 excludeParts.add(part);
8276 }
8377 }