OmegaT の背景に画像を表示します。
ConfigSet を groovy.util.ConfigSlurper ベースに移行
| @@ -16,16 +16,14 @@ | ||
| 16 | 16 | |
| 17 | 17 | package jp.sourceforge.users.yutang.omegat.plugin.moenizer.config; |
| 18 | 18 | |
| 19 | -import java.io.BufferedReader; | |
| 19 | +import groovy.util.ConfigObject; | |
| 20 | +import groovy.util.ConfigSlurper; | |
| 20 | 21 | import java.io.BufferedWriter; |
| 21 | 22 | import java.io.File; |
| 22 | -import java.io.FileInputStream; | |
| 23 | 23 | import java.io.FileWriter; |
| 24 | 24 | import java.io.IOException; |
| 25 | -import java.io.InputStreamReader; | |
| 26 | 25 | import java.io.Writer; |
| 27 | 26 | import java.util.Properties; |
| 28 | -import org.omegat.util.OConsts; | |
| 29 | 27 | |
| 30 | 28 | /** |
| 31 | 29 | * Manage config collection |
| @@ -35,7 +33,7 @@ | ||
| 35 | 33 | public class ConfigSet { |
| 36 | 34 | |
| 37 | 35 | private final File file; |
| 38 | - private final Properties properties; | |
| 36 | + private ConfigObject config = null; | |
| 39 | 37 | |
| 40 | 38 | public static Properties getDefaultProperties() { |
| 41 | 39 | Properties p = new Properties(); |
| @@ -46,23 +44,10 @@ | ||
| 46 | 44 | return p; |
| 47 | 45 | } |
| 48 | 46 | |
| 49 | - public ConfigSet(Properties defaultProperties, File file) throws IOException { | |
| 47 | + public ConfigSet(File file) throws IOException { | |
| 50 | 48 | this.file = file; |
| 51 | - properties = new Properties(defaultProperties); | |
| 52 | - | |
| 53 | 49 | if (file.isFile()) { |
| 54 | - BufferedReader reader = null; | |
| 55 | - try { | |
| 56 | - FileInputStream in = new FileInputStream(file); | |
| 57 | - reader = new BufferedReader(new InputStreamReader(in, OConsts.UTF8)); | |
| 58 | - properties.load(reader); | |
| 59 | - } finally { | |
| 60 | - try { | |
| 61 | - if (reader != null) { | |
| 62 | - reader.close(); | |
| 63 | - } | |
| 64 | - } catch(IOException ex) { /* ignore */ } | |
| 65 | - } | |
| 50 | + config = new ConfigSlurper().parse(file.toURI().toURL()); | |
| 66 | 51 | } |
| 67 | 52 | } |
| 68 | 53 |
| @@ -70,7 +55,7 @@ | ||
| 70 | 55 | Writer writer = null; |
| 71 | 56 | try { |
| 72 | 57 | writer = new BufferedWriter(new FileWriter(file)); |
| 73 | - properties.store(writer, null); | |
| 58 | + config.writeTo(writer); | |
| 74 | 59 | } finally { |
| 75 | 60 | try { |
| 76 | 61 | if (writer != null) { |
| @@ -24,7 +24,7 @@ | ||
| 24 | 24 | public abstract class Config { |
| 25 | 25 | |
| 26 | 26 | enum ProviderType { |
| 27 | - Color, Image | |
| 27 | + Color, SimpleImage | |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | private final String name; |