• 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

Revision35 (tree)
Time2014-05-19 21:52:22
Authoryu-tang

Log Message

テーマ切り替え用クラス ThemeChanger を追加

Change Summary

Incremental Difference

--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/MoeConfig.java (revision 34)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/MoeConfig.java (revision 35)
@@ -46,13 +46,12 @@
4646 public enum ProviderType {
4747 Color, SimpleImage
4848 }
49- private final String CONF_GENERAL = "__general__";
5049 private final String KEY_INDEX = "index";
51- private final String KEY_ENABLED = "enabled";
50+ private final String KEY_ISACTIVE = "isActive";
5251
5352 private final File file;
5453 private ConfigObject config = null;
55- private final TreeSet<ConfigObject> providerConfigs
54+ private final TreeSet<ConfigObject> sortedConfigs
5655 = new TreeSet<ConfigObject>
5756 (new Comparator<ConfigObject>() {
5857 @Override
@@ -62,13 +61,12 @@
6261 return index1 - index2;
6362 }
6463 });
65-;
6664
6765 public MoeConfig(File file) throws IOException {
6866 this.file = file;
6967 if (file.isFile()) {
7068 config = new ConfigSlurper().parse(file.toURI().toURL());
71- buildProviderConfigs(config);
69+ addAll(sortedConfigs, config);
7270 }
7371 }
7472
@@ -88,21 +86,23 @@
8886 }
8987
9088 public Set<ConfigObject> getProviderConfigs() {
91- return providerConfigs;
89+ return sortedConfigs;
9290 }
9391
9492 public ConfigObject getCurrentConfig() {
95- for (ConfigObject entry : providerConfigs) {
96- boolean enabled = (Boolean) entry.get(KEY_ENABLED);
97- if (enabled) {
98- return entry;
93+ for (ConfigObject entry : sortedConfigs) {
94+ if (entry.containsKey(KEY_ISACTIVE)) {
95+ boolean isActive = (Boolean) entry.get(KEY_ISACTIVE);
96+ if (isActive) {
97+ return entry;
98+ }
9999 }
100100 }
101101
102- // No enabled config found. Fallback to default config.
102+ // No active config found. Fallback to default config.
103103 ConfigObject defaultConfig = getDefaultConfig();
104- boolean enabled = (Boolean) defaultConfig.get(KEY_ENABLED);
105- return enabled ? defaultConfig : null;
104+ boolean isActive = (Boolean) defaultConfig.get(KEY_ISACTIVE);
105+ return isActive ? defaultConfig : null;
106106 }
107107
108108 public void save() throws IOException {
@@ -119,14 +119,12 @@
119119 }
120120 }
121121
122- private void buildProviderConfigs(ConfigObject config) {
122+ private void addAll(Set<ConfigObject> sortedConfigs, ConfigObject config) {
123123 for (Object entry : config.entrySet()) {
124124 Map.Entry<String, ConfigObject> e = (Map.Entry<String, ConfigObject>) entry;
125- String name = e.getKey();
125+ //String name = e.getKey();
126126 ConfigObject conf = e.getValue();
127- if (!name.equals(CONF_GENERAL)) {
128- providerConfigs.add(conf);
129- }
127+ sortedConfigs.add(conf);
130128 }
131129 }
132130
@@ -152,14 +150,21 @@
152150 }
153151 }
154152
155- ConfigObject conf = new ConfigObject();
156- conf.put("index", -1);
157- conf.put("enabled", !image.isEmpty());
158- conf.put("providerType", ProviderType.SimpleImage.name());
159- conf.put("opacity", 0.5f); // 0.0f (Transparent) <--> 1.0f (Opaque)
160- conf.put("image", image);
153+ ConfigObject effect = new ConfigObject();
154+ effect.put("type", ProviderType.SimpleImage.name());
155+ effect.put("target", "mainWindow");
156+ effect.put("opacity", 0.5f); // 0.0f (Transparent) <--> 1.0f (Opaque)
157+ effect.put("image", image);
158+
159+ List<ConfigObject> effects = new ArrayList<ConfigObject>(1);
160+ effects.add(effect);
161161
162- return conf;
162+ ConfigObject node = new ConfigObject();
163+ node.put("index", -1);
164+ node.put("isActive", !image.isEmpty());
165+ node.put("effects", effects);
166+
167+ return node;
163168 }
164169
165170 private static String getFirstImagePath(File parentDir) {
--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/Moenizer.java (revision 34)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/Moenizer.java (revision 35)
@@ -16,6 +16,7 @@
1616
1717 package jp.sourceforge.users.yutang.omegat.plugin.moenizer;
1818
19+import groovy.util.ConfigObject;
1920 import java.awt.image.BufferedImage;
2021 import java.util.concurrent.TimeUnit;
2122 import javax.swing.SwingUtilities;
@@ -40,6 +41,7 @@
4041 private IImageLoader imageLoader;
4142 private MoeUI ui;
4243 private MoeConfig config;
44+ private ThemeChanger themeChanger;
4345
4446 public static void loadPlugins() {
4547 try {
@@ -75,10 +77,7 @@
7577 (new SlideShow()).execute();
7678
7779 ui = MoeUI.getInstance();
78- ui.setMakeTransparentMenubar(getMakeTransparentMenubar());
79- ui.setMakeTransparentButtonPanel(getMakeTransparentButtonPanel());
80- ui.setMakeTransparentStatusbar(getMakeTransparentStatusbar());
81- ui.setMakeTransparentPaneTitlebar(getMakeTransparentPaneTitlebar());
80+ themeChanger = new ThemeChanger(config.getCurrentConfig());
8281
8382 // この時点でコンポーネントの透過設定をしても反映されない(タイミング?)。
8483 // Workaround として、invokeLater でキューに突っ込んで、後で処理する。
@@ -87,6 +86,7 @@
8786 public void run() {
8887 CoreEvents.unregisterApplicationEventListener(Moenizer.this);
8988 ui.transparent();
89+ themeChanger.apply();
9090 }
9191 });
9292 //CoreEvents.unregisterApplicationEventListener(this); // ここで発行すると、スレッドエラーになるので注意
@@ -124,22 +124,6 @@
124124 }
125125 }
126126
127- private boolean getMakeTransparentMenubar() {
128- return config.get("__general__.makeTransparentMenubar", true);
129- }
130-
131- private boolean getMakeTransparentButtonPanel() {
132- return config.get("__general__.makeTransparentButtonPanel", true);
133- }
134-
135- private boolean getMakeTransparentStatusbar() {
136- return config.get("__general__.makeTransparentStatusbar", true);
137- }
138-
139- private boolean getMakeTransparentPaneTitlebar() {
140- return config.get("__general__.makeTransparentPaneTitlebar", true);
141- }
142-
143127 private class SlideShow extends SwingWorker<Object, Void> {
144128 private long interval = -1;
145129
--- trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/ThemeChanger.java (nonexistent)
+++ trunk/src/jp/sourceforge/users/yutang/omegat/plugin/moenizer/ThemeChanger.java (revision 35)
@@ -0,0 +1,44 @@
1+/**************************************************************************
2+ Moenizer - Allow to set background image for OmegaT.
3+
4+ Copyright (C) 2014 Yu Tang
5+ Home page: http://sourceforge.jp/users/yu-tang/
6+ Support center: http://sourceforge.jp/users/yu-tang/pf/Moenizer/
7+
8+ This file is part of plugin for OmegaT.
9+ http://www.omegat.org/
10+
11+ License: GNU GPL version 3 or (at your option) any later version.
12+
13+ You should have received a copy of the GNU General Public License
14+ along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ **************************************************************************/
16+
17+package jp.sourceforge.users.yutang.omegat.plugin.moenizer;
18+
19+import groovy.util.ConfigObject;
20+
21+/**
22+ *
23+ * @author Yu-Tang
24+ */
25+public class ThemeChanger {
26+
27+ private ConfigObject config;
28+
29+ public ThemeChanger(ConfigObject config) {
30+ this.config = config;
31+ }
32+
33+ public void apply() {
34+ if (config == null) {
35+ return;
36+ }
37+
38+
39+
40+
41+
42+
43+ }
44+}