OSDN Git Service

キャラクターデータの独自独自テンプレートの作成機能の追加
authorseraphy <seraphy@5b6e9025-a2e8-4882-b233-f889982098c5>
Sun, 24 Nov 2013 22:46:55 +0000 (22:46 +0000)
committerseraphy <seraphy@5b6e9025-a2e8-4882-b233-f889982098c5>
Sun, 24 Nov 2013 22:46:55 +0000 (22:46 +0000)
git-svn-id: https://svn.sourceforge.jp/svnroot/charactermanaj/trunk@85 5b6e9025-a2e8-4882-b233-f889982098c5

31 files changed:
resources/languages/profileselectordialog.xml
resources/languages/profileselectordialog_ja.xml
src/charactermanaj/graphics/io/ImageSaveHelper.java
src/charactermanaj/graphics/io/UkagakaImageSaveHelper.java
src/charactermanaj/model/io/CharacterDataDefaultProvider.java
src/charactermanaj/ui/AppConfigDialog.java
src/charactermanaj/ui/ArchiveFileChooser.java
src/charactermanaj/ui/ColorBox.java
src/charactermanaj/ui/ColorDialog.java
src/charactermanaj/ui/ExportWizardDialog.java
src/charactermanaj/ui/ImageSelectPanel.java
src/charactermanaj/ui/ImportWizardDialog.java
src/charactermanaj/ui/InformationDialog.java
src/charactermanaj/ui/MainFrame.java
src/charactermanaj/ui/ManageFavoriteDialog.java
src/charactermanaj/ui/MenuBuilder.java
src/charactermanaj/ui/PartsManageDialog.java
src/charactermanaj/ui/PreviewPanel.java
src/charactermanaj/ui/ProfileEditDialog.java
src/charactermanaj/ui/ProfileSelectorDialog.java
src/charactermanaj/ui/SamplePicturePanel.java
src/charactermanaj/ui/SearchPartsDialog.java
src/charactermanaj/ui/SelectCharatersDirDialog.java
src/charactermanaj/ui/UkagakaConvertDialog.java
src/charactermanaj/ui/WallpaperDialog.java
src/charactermanaj/ui/model/PredefinedWallpaper.java
src/charactermanaj/ui/util/SingleRootFileSystemView.java [new file with mode: 0644]
src/charactermanaj/util/LocalizedResourcePropertyLoader.java
src/charactermanaj/util/ResourceLoader.java
src/charactermanaj/util/ResourceNames.java
src/charactermanaj/util/SetupLocalization.java

index 140e0e2..e2289e1 100644 (file)
@@ -4,13 +4,14 @@
        <entry key="windowHeight">500</entry>\r
        <entry key="title">Profile Selector</entry>\r
        <entry key="profile.new">New</entry>\r
-       <entry key="profile.copy">Copy Struct.</entry>\r
+       <entry key="profile.copy">Copy Structure</entry>\r
        <entry key="profile.edit">Edit</entry>\r
        <entry key="profile.edit.readonly">View</entry>\r
        <entry key="profile.remove">Remove</entry>\r
        <entry key="profile.browse">Browse</entry>\r
        <entry key="profile.import">Import</entry>\r
        <entry key="profile.export">Export</entry>\r
+       <entry key="profile.template">Create Template</entry>\r
        <entry key="profileNew.chooseTemplate.title">Choose a Character Data Template</entry>\r
        <entry key="description">Description</entry>\r
        <entry key="profiles">Profiles</entry>\r
@@ -44,4 +45,9 @@
        <entry key="profile.column.description.width">300</entry>\r
        <entry key="profile.column.author.width">150</entry>\r
        <entry key="profile.column.location.width">300</entry>\r
+\r
+       <entry key="inputTemplateName">Template Name</entry>\r
+       <entry key="confirm">Confirm</entry>\r
+       <entry key="confirmOverwrite"><![CDATA[file already exists.\r
+Do you want to replace it?]]></entry>\r
 </properties>\r
index cb0016d..e49d1fd 100644 (file)
@@ -11,6 +11,7 @@
        <entry key="profile.browse">場所を開く</entry>\r
        <entry key="profile.import">インポート</entry>\r
        <entry key="profile.export">エクスポート</entry>\r
+       <entry key="profile.template">テンプレートの作成</entry>\r
        <entry key="profileNew.chooseTemplate.title">キャラクターデータのテンプレートの選択</entry>\r
        <entry key="description">プロファイルの説明</entry>\r
        <entry key="profiles">プロファイル一覧</entry>\r
@@ -44,4 +45,9 @@
        <entry key="profile.column.description.width">300</entry>\r
        <entry key="profile.column.author.width">150</entry>\r
        <entry key="profile.column.location.width">300</entry>\r
+\r
+       <entry key="inputTemplateName">テンプレートの名前</entry>\r
+       <entry key="confirm">確認</entry>\r
+       <entry key="confirmOverwrite"><![CDATA[ファイルは既に存在します。\r
+上書きしてもよろしいですか?]]></entry>\r
 </properties>\r
index 7b30e6b..f1882e7 100644 (file)
@@ -238,7 +238,7 @@ public class ImageSaveHelper {
                                \r
                                // ファイルが存在すれば上書き確認する.\r
                                if (outFile.exists()) {\r
-                                       Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+                                       Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                                .getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                                        if (JOptionPane.showConfirmDialog(this,\r
@@ -542,7 +542,7 @@ class OutputOptionPanel extends JPanel {
 \r
        public OutputOptionPanel(OutputOption outputOption) {\r
 \r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                        .getLocalizedProperties(ImageSaveHelper.STRINGS_RESOURCE);\r
 \r
                setBorder(BorderFactory.createCompoundBorder(\r
index b526239..37e0725 100644 (file)
@@ -93,7 +93,7 @@ public class UkagakaImageSaveHelper {
         * コンストラクタ\r
         */\r
        public UkagakaImageSaveHelper() {\r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                        .getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                lastUseSaveName = strings.getProperty("default.lastUseSaveName"); \r
@@ -120,7 +120,7 @@ public class UkagakaImageSaveHelper {
                                }\r
 \r
                                if (save && outFile.exists()) {\r
-                                       Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+                                       Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                                .getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                                        if (JOptionPane.showConfirmDialog(this,\r
index f289f9e..1585335 100644 (file)
@@ -1,9 +1,17 @@
 package charactermanaj.model.io;\r
 \r
+import java.io.BufferedInputStream;\r
+import java.io.BufferedOutputStream;\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
 import java.io.FileNotFoundException;\r
+import java.io.FileOutputStream;\r
 import java.io.IOException;\r
 import java.io.InputStream;\r
 import java.net.URL;\r
+import java.sql.Timestamp;\r
+import java.util.EnumSet;\r
+import java.util.Enumeration;\r
 import java.util.LinkedHashMap;\r
 import java.util.Map;\r
 import java.util.Properties;\r
@@ -11,15 +19,17 @@ import java.util.logging.Level;
 import java.util.logging.Logger;\r
 \r
 import charactermanaj.model.CharacterData;\r
+import charactermanaj.util.ConfigurationDirUtilities;\r
 import charactermanaj.util.LocalizedResourcePropertyLoader;\r
 import charactermanaj.util.ResourceLoader;\r
+import charactermanaj.util.SetupLocalization;\r
 \r
 /**\r
  * デフォルトキャラクターセットのプロバイダ\r
  * \r
  * @author seraphy\r
  */\r
-public class CharacterDataDefaultProvider extends ResourceLoader {\r
+public class CharacterDataDefaultProvider {\r
 \r
        /**\r
         * リソースに格納されているデフォルトのキャラクター定義のリソースパスまでのプレフィックス.<br>\r
@@ -27,6 +37,11 @@ public class CharacterDataDefaultProvider extends ResourceLoader {
        public static final String DEFAULT_CHARACTER_PREFIX = "template/";\r
 \r
        /**\r
+        * テンプレートをリストしているXML形式のプロパティファイル名\r
+        */\r
+       public static final String TEMPLATE_LIST_XML = "characterDataTemplates";\r
+\r
+       /**\r
         * デフォルトのキャラクターセット名(ver2)\r
         */\r
        public static final String DEFAULT_CHARACTER_NAME_V2 = "character2.xml";\r
@@ -95,17 +110,40 @@ public class CharacterDataDefaultProvider extends ResourceLoader {
         * @return 順序付マップ\r
         */\r
        public Map<String, String> getCharacterDataTemplates() {\r
-               Properties props = LocalizedResourcePropertyLoader.getInstance()\r
-                               .getLocalizedProperties("template/characterDataTemplates");\r
+               // テンプレートリソースは実行中に増減する可能性があるため、\r
+               // 共有キャッシュには入れない.\r
+               LocalizedResourcePropertyLoader propLoader = new LocalizedResourcePropertyLoader(\r
+                               null);\r
+               Properties props = propLoader.getLocalizedProperties("template/"\r
+                               + TEMPLATE_LIST_XML);\r
 \r
                LinkedHashMap<String, String> results = new LinkedHashMap<String, String>();\r
 \r
+               // 順序優先\r
                String strOrders = props.getProperty("displayOrder");\r
                if (strOrders != null) {\r
                        for (String key : strOrders.split(",")) {\r
                                key = key.trim();\r
                                String val = props.getProperty(key);\r
                                if (val != null && val.trim().length() > 0) {\r
+                                       String resKey = DEFAULT_CHARACTER_PREFIX + key;\r
+                                       if (getResource(resKey) != null) {\r
+                                               // 現存するテンプレートのみ登録\r
+                                               results.put(key, val);\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+\r
+               // 順序が指定されていないアイテムの追加\r
+               Enumeration<?> enm = props.propertyNames();\r
+               while (enm.hasMoreElements()) {\r
+                       String key = (String) enm.nextElement();\r
+                       String val = props.getProperty(key);\r
+                       if (key.endsWith(".xml")) {\r
+                               String resKey = DEFAULT_CHARACTER_PREFIX + key;\r
+                               if (getResource(resKey) != null) {\r
+                                       // 現存するテンプレートのみ登録\r
                                        results.put(key, val);\r
                                }\r
                        }\r
@@ -144,4 +182,123 @@ public class CharacterDataDefaultProvider extends ResourceLoader {
                }\r
                return cd;\r
        }\r
+\r
+       /**\r
+        * リソースを取得する.<br>\r
+        * \r
+        * @param resKey\r
+        *            リソースキー\r
+        * @return リソース、なければnull\r
+        */\r
+       protected URL getResource(String resKey) {\r
+               ResourceLoader resourceLoader = new ResourceLoader();\r
+               return resourceLoader.getResource(resKey);\r
+       }\r
+\r
+       /**\r
+        * カスタマイズ用のテンプレートディレクトリを取得する.<br>\r
+        * まだ作成されていない場合で、prepareが指示されている場合はフォルダを準備し、 既定のファイルを作成する.<br>\r
+        * \r
+        * @param prepare\r
+        *            実際にディレクトリを準備する場合はtrue\r
+        * @return テンプレートディレクトリ\r
+        */\r
+       public File getTemplateDir(boolean prepare) throws IOException {\r
+               File baseDir = ConfigurationDirUtilities.getUserDataDir();\r
+               SetupLocalization setup = new SetupLocalization(baseDir);\r
+               File resourceDir = setup.getResourceDir();\r
+\r
+               if (prepare) {\r
+                       // テンプレートリソースが未設定であれば設定する.\r
+                       setup.setupToLocal(\r
+                                       EnumSet.of(SetupLocalization.Resources.Template), false);\r
+\r
+                       // ディレクトリがなければ作成しておく\r
+                       if (resourceDir.exists()) {\r
+                               resourceDir.mkdirs();\r
+                       }\r
+               }\r
+               return new File(resourceDir, DEFAULT_CHARACTER_PREFIX);\r
+       }\r
+\r
+       /**\r
+        * "characterDataTemplates*.xml"のファイルは管理ファイルのため、 <br>\r
+        * ユーザによる書き込みは禁止とする.<br>\r
+        * \r
+        * @param name\r
+        * @return 書き込み可能であるか?\r
+        */\r
+       public boolean canFileSave(String name) {\r
+               if (name.trim().startsWith("characterDataTemplates")) {\r
+                       return false;\r
+               }\r
+               return true;\r
+       }\r
+\r
+       /**\r
+        * 指定したキャラクターデータをテンプレートとして保存する.<br>\r
+        * \r
+        * @param name\r
+        *            保存するテンプレートファイル名\r
+        * @param cd\r
+        *            キャラクターデータ\r
+        * @param localizedName\r
+        *            表示名\r
+        * @throws IOException\r
+        */\r
+       public void saveTemplate(String name, CharacterData cd, String localizedName)\r
+                       throws IOException {\r
+               if (name == null || !canFileSave(name)) {\r
+                       throw new IllegalArgumentException();\r
+               }\r
+\r
+               // テンプレートファイル位置の準備\r
+               // (リソースが、まだファイルに展開されていなれば展開する)\r
+               File templDir = getTemplateDir(true);\r
+               File templFile = new File(templDir, name);\r
+\r
+               // キャラクターデータをXML形式でテンプレートファイルへ保存\r
+               CharacterDataXMLWriter characterDataXmlWriter = new CharacterDataXMLWriter();\r
+               BufferedOutputStream bos = new BufferedOutputStream(\r
+                               new FileOutputStream(templFile));\r
+               try {\r
+                       // パーツセットなしの状態とし、名前をローカライズ名に設定する.\r
+                       CharacterData templCd = cd.duplicateBasicInfo(false);\r
+                       templCd.setName(localizedName);\r
+\r
+                       characterDataXmlWriter.writeXMLCharacterData(templCd, bos);\r
+\r
+               } finally {\r
+                       bos.close();\r
+               }\r
+\r
+               // 現在のテンプレート一覧のファイルリソースの読み込み\r
+               // (言語中立のリソースのみ)\r
+               Properties neutralProps = new Properties();\r
+               File neutralPropsFile = new File(templDir, TEMPLATE_LIST_XML + ".xml");\r
+               if (neutralPropsFile.exists()) {\r
+                       BufferedInputStream bis = new BufferedInputStream(\r
+                                       new FileInputStream(neutralPropsFile));\r
+                       try {\r
+                               neutralProps.loadFromXML(bis);\r
+\r
+                       } finally {\r
+                               bis.close();\r
+                       }\r
+               }\r
+\r
+               // テンプレート一覧の更新\r
+               neutralProps.put(name, localizedName);\r
+\r
+               // テンプレート一覧の保存\r
+               BufferedOutputStream fos = new BufferedOutputStream(\r
+                               new FileOutputStream(neutralPropsFile));\r
+               try {\r
+                       neutralProps.storeToXML(fos,\r
+                                       new Timestamp(System.currentTimeMillis()).toString());\r
+\r
+               } finally {\r
+                       bos.close();\r
+               }\r
+       }\r
 }\r
index 15a335d..55b1f6c 100644 (file)
@@ -15,6 +15,7 @@ import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;\r
 import java.io.File;\r
 import java.util.Collections;\r
+import java.util.EnumSet;\r
 import java.util.Properties;\r
 import java.util.Set;\r
 import java.util.logging.Level;\r
@@ -94,7 +95,7 @@ public class AppConfigDialog extends JDialog {
        \r
        private void initComponent() {\r
                \r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties("languages/appconfigdialog");\r
                \r
                setTitle(strings.getProperty("title"));\r
@@ -274,7 +275,7 @@ public class AppConfigDialog extends JDialog {
         * ローカライズリソースをユーザディレクトリ上に展開する.\r
         */\r
        protected void onSetupLocalization() {\r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                        .getLocalizedProperties("languages/appconfigdialog");\r
                if (JOptionPane.showConfirmDialog(this,\r
                                strings.getProperty("setupLocalization"),\r
@@ -286,7 +287,8 @@ public class AppConfigDialog extends JDialog {
                try {\r
                        File baseDir = ConfigurationDirUtilities.getUserDataDir();\r
                        SetupLocalization setup = new SetupLocalization(baseDir);\r
-                       setup.setupToLocal();\r
+                       setup.setupToLocal(\r
+                                       EnumSet.allOf(SetupLocalization.Resources.class), true);\r
 \r
                        File resourceDir = setup.getResourceDir();\r
                        DesktopUtilities.open(resourceDir);\r
@@ -298,7 +300,7 @@ public class AppConfigDialog extends JDialog {
        \r
        protected void onClose() {\r
                if (appConfigTableModel.isModified()) {\r
-                       Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+                       Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                        .getLocalizedProperties("languages/appconfigdialog");\r
                        if (JOptionPane.showConfirmDialog(this, strings.getProperty("confirm.close"),\r
                                        strings.getProperty("confirm.close.caption"), JOptionPane.YES_NO_OPTION,\r
@@ -318,7 +320,7 @@ public class AppConfigDialog extends JDialog {
                        return;\r
                }\r
                \r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties("languages/appconfigdialog");\r
 \r
                // 編集されたプロパティを取得する.\r
@@ -453,7 +455,7 @@ class AppConfigTableModel extends AbstractTableModelWithComboBoxModel<AppConfigR
        private Properties original;\r
        \r
        static {\r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties("languages/appconfigdialog");\r
 \r
                COLUMN_NAMES = new String[] {\r
@@ -474,7 +476,7 @@ class AppConfigTableModel extends AbstractTableModelWithComboBoxModel<AppConfigR
                if (original != null) {\r
                        target.putAll(original);\r
                        \r
-                       Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+                       Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                        .getLocalizedProperties("languages/appconfigdialog");\r
 \r
                        for (Object key : target.keySet()) {\r
index e3fbafb..59ccd04 100644 (file)
@@ -95,7 +95,7 @@ public class ArchiveFileChooser extends JFileChooser {
                        }\r
                }\r
                \r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                if (writeMode && file.exists()) {\r
index a2a4d80..90ffd6c 100644 (file)
@@ -80,7 +80,7 @@ public class ColorBox extends JPanel {
                }\r
                this.colorKey = colorKey;\r
 \r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                        .getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                colorDisplayPanel = createColorDiaplyPanel();\r
@@ -222,7 +222,7 @@ public class ColorBox extends JPanel {
        }\r
     \r
     protected String getColorDialogTitle() {\r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                        .getLocalizedProperties(STRINGS_RESOURCE);\r
                return strings.getProperty("caption.chooseColorKey");\r
        }\r
index 5d2cea9..84c69ad 100644 (file)
@@ -138,7 +138,7 @@ public class ColorDialog extends JDialog {
                super(parent);\r
                this.partsCategory = partsCategory;\r
 \r
-               final Properties strings = LocalizedResourcePropertyLoader.getInstance().getLocalizedProperties("languages/colordialog");\r
+               final Properties strings = LocalizedResourcePropertyLoader.getCachedInstance().getLocalizedProperties("languages/colordialog");\r
                \r
                String caption = strings.getProperty("colordialog.caption");\r
                String name = partsCategory.getLocalizedCategoryName();\r
@@ -711,7 +711,7 @@ class ColorDialogTabPanel extends JPanel {
                }\r
                this.parent = parent;\r
 \r
-               final Properties strings = LocalizedResourcePropertyLoader.getInstance().getLocalizedProperties("languages/colordialog");\r
+               final Properties strings = LocalizedResourcePropertyLoader.getCachedInstance().getLocalizedProperties("languages/colordialog");\r
 \r
                setLayout(new BorderLayout());\r
                JPanel container = new JPanel();\r
index ec28b44..2742e10 100644 (file)
@@ -144,7 +144,7 @@ public class ExportWizardDialog extends JDialog {
                        }\r
                });\r
                \r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                // タイトル\r
@@ -343,7 +343,7 @@ public class ExportWizardDialog extends JDialog {
        }\r
        \r
        protected void onClose() {\r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(ExportWizardDialog.STRINGS_RESOURCE);\r
 \r
                if (JOptionPane.showConfirmDialog(this,\r
@@ -389,7 +389,7 @@ public class ExportWizardDialog extends JDialog {
                        }\r
 \r
                        // 完了メッセージ\r
-                       Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+                       Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                        .getLocalizedProperties(ExportWizardDialog.STRINGS_RESOURCE);\r
                        JOptionPane.showMessageDialog(this, strings.getProperty("complete"));\r
                        \r
@@ -576,7 +576,7 @@ class ExportInformationPanel extends AbstractImportPanel implements ExportInform
                setName("basicPanel");\r
                this.samplePicture = samplePicture;\r
 \r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(ExportWizardDialog.STRINGS_RESOURCE);\r
 \r
                GridBagLayout basicPanelLayout = new GridBagLayout();\r
@@ -795,7 +795,7 @@ class ExportPartsSelectPanel extends AbstractImportPanel implements ExportPartsR
                        throw new IllegalArgumentException();\r
                }\r
 \r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(ExportWizardDialog.STRINGS_RESOURCE);\r
 \r
                setName("choosePartsPanel");\r
@@ -1027,7 +1027,7 @@ class ExportPresetSelectPanel extends AbstractImportPanel implements ExportPrese
                \r
                setName("presetSelectPanel");\r
 \r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(ExportWizardDialog.STRINGS_RESOURCE);\r
 \r
                setName("choosePartsPanel");\r
@@ -1264,7 +1264,7 @@ class ExportPartsTableModel extends AbstractTableModelWithComboBoxModel<ExportPa
        private boolean enabled = true;\r
 \r
        static {\r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(ExportWizardDialog.STRINGS_RESOURCE);\r
 \r
                columnNames = new String[] {\r
@@ -1616,7 +1616,7 @@ class ExportPresetTableModel extends AbstractTableModelWithComboBoxModel<ExportP
        private boolean enabled = true;\r
 \r
        static {\r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(ExportWizardDialog.STRINGS_RESOURCE);\r
 \r
                columnNames = new String[] {\r
index 5247780..0515d5b 100644 (file)
@@ -255,7 +255,7 @@ public class ImageSelectPanel extends JPanel {
 \r
                AppConfig appConfig = AppConfig.getInstance();\r
                \r
-               final Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               final Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(STRINGS_RESOURCE);\r
                \r
                final Color selectedItemColor = appConfig.getCheckedItemBgColor();\r
index 9ead178..502e466 100644 (file)
@@ -213,7 +213,7 @@ public class ImportWizardDialog extends JDialog {
                        }\r
                });\r
                \r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                // タイトル\r
@@ -429,7 +429,7 @@ public class ImportWizardDialog extends JDialog {
        }\r
        \r
        protected void onClose() {\r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(STRINGS_RESOURCE);\r
                \r
                if (JOptionPane.showConfirmDialog(this,\r
@@ -455,7 +455,7 @@ public class ImportWizardDialog extends JDialog {
         * インポートの実行.<br>\r
         */\r
        protected void onFinish() {\r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(ImportWizardDialog.STRINGS_RESOURCE);\r
 \r
                try {\r
@@ -776,7 +776,7 @@ class ImportFileSelectPanel extends ImportWizardCardPanel {
        public ImportFileSelectPanel() {\r
                setLayout(new BorderLayout());\r
                \r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(ImportWizardDialog.STRINGS_RESOURCE);\r
 \r
                DocumentListener documentListener = new DocumentListener() {\r
@@ -1041,7 +1041,7 @@ class ImportFileSelectPanel extends ImportWizardCardPanel {
                        return null;\r
                }\r
 \r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                        .getLocalizedProperties(ImportWizardDialog.STRINGS_RESOURCE);\r
 \r
                URI importArchive;\r
@@ -1260,7 +1260,7 @@ class ImportTypeSelectPanel extends ImportWizardCardPanel {
        /* 以下、選択結果 */\r
        \r
        public ImportTypeSelectPanel() {\r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(ImportWizardDialog.STRINGS_RESOURCE);\r
 \r
                GridBagLayout basicPanelLayout = new GridBagLayout();\r
@@ -1467,7 +1467,7 @@ class ImportTypeSelectPanel extends ImportWizardCardPanel {
                        return;\r
                }\r
 \r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(ImportWizardDialog.STRINGS_RESOURCE);\r
 \r
                // 呼び出しもと情報\r
@@ -1707,7 +1707,7 @@ class ImportPartsSelectPanel extends ImportWizardCardPanel {
 \r
        \r
        public ImportPartsSelectPanel() {\r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(ImportWizardDialog.STRINGS_RESOURCE);\r
 \r
                setLayout(new BorderLayout());\r
@@ -2415,7 +2415,7 @@ class ImportPartsTableModel extends AbstractTableModelWithComboBoxModel<ImportPa
        private Set<PartsIdentifier> currentProfilePartsIdentifiers;\r
        \r
        static {\r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(ImportWizardDialog.STRINGS_RESOURCE);\r
                \r
                COLUMN_NAMES = new String[] {\r
@@ -2850,7 +2850,7 @@ class ImportPresetSelectPanel extends ImportWizardCardPanel {
        private Action actSelectUsedParts;\r
 \r
        public ImportPresetSelectPanel() {\r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(ImportWizardDialog.STRINGS_RESOURCE);\r
 \r
                setBorder(BorderFactory.createTitledBorder(strings.getProperty("preset.title")));\r
@@ -3185,7 +3185,7 @@ class ImportPresetTableModel extends AbstractTableModelWithComboBoxModel<ImportP
        private static final int[] COLUMN_WIDTHS; // = {50, 100, 200};\r
        \r
        static {\r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(ImportWizardDialog.STRINGS_RESOURCE);\r
                \r
                COLUMN_NAMES = new String[] {\r
index 207fbab..3ad4b53 100644 (file)
@@ -104,7 +104,7 @@ public class InformationDialog extends JDialog {
                });\r
                \r
                final Properties strings = LocalizedResourcePropertyLoader\r
-                               .getInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
+                               .getCachedInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
                \r
                setTitle(strings.getProperty("title"));\r
                \r
@@ -298,7 +298,7 @@ class InformationTableModel extends AbstractTableModelWithComboBoxModel<Informat
        \r
        static {\r
                final Properties strings = LocalizedResourcePropertyLoader\r
-                               .getInstance().getLocalizedProperties(InformationDialog.STRINGS_RESOURCE);\r
+                               .getCachedInstance().getLocalizedProperties(InformationDialog.STRINGS_RESOURCE);\r
 \r
                columnNames = new String[] {\r
                                strings.getProperty("column.partsName"),\r
index 9163ad3..f7e2b8b 100644 (file)
@@ -609,7 +609,7 @@ public class MainFrame extends JFrame {
                \r
                // 設定まわり準備\r
                AppConfig appConfig = AppConfig.getInstance();\r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                // タイトル表示\r
@@ -1266,7 +1266,7 @@ public class MainFrame extends JFrame {
        protected void onChangeBgColor() {\r
                getJMenuBar().setEnabled(false);\r
                try {\r
-                       Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+                       Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                        .getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                        Color color = wallpaperInfo.getBackgroundColor();\r
@@ -1718,7 +1718,7 @@ public class MainFrame extends JFrame {
                        return;\r
                }\r
                \r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(STRINGS_RESOURCE);\r
                \r
                if (JOptionPane.showConfirmDialog(this, strings.get("confirm.resetcolors"), strings.getProperty("confirm"),\r
@@ -1961,7 +1961,7 @@ public class MainFrame extends JFrame {
        }\r
 \r
        protected void onHelp() {\r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                        .getLocalizedProperties(STRINGS_RESOURCE);\r
                String helpURL = strings.getProperty("help.url");\r
                String helpDescription = strings.getProperty("help.show");\r
@@ -2095,7 +2095,7 @@ public class MainFrame extends JFrame {
                                return;\r
                        }\r
 \r
-                       Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+                       Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                        .getLocalizedProperties(STRINGS_RESOURCE);\r
                        \r
                        // お気に入りに登録するパーツセットが最後に使用したお気に入りと同じ構成であれば、\r
@@ -2205,7 +2205,7 @@ public class MainFrame extends JFrame {
         */\r
        protected JMenuBar createMenuBar() {\r
                final Properties strings = LocalizedResourcePropertyLoader\r
-                               .getInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
+                               .getCachedInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
                \r
                MenuDataFactory[] menus = new MenuDataFactory[] {\r
                                new MenuDataFactory("menu.file", new MenuDataFactory[] {\r
index b94c2b6..a0ae6e8 100644 (file)
@@ -86,7 +86,7 @@ public class ManageFavoriteDialog extends JDialog {
                });\r
                \r
                Properties strings = LocalizedResourcePropertyLoader\r
-                               .getInstance()\r
+                               .getCachedInstance()\r
                                .getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                setTitle(strings.getProperty("manageFavorites"));\r
@@ -235,7 +235,7 @@ public class ManageFavoriteDialog extends JDialog {
         */\r
        protected void onDelete() {\r
                // 削除の確認ダイアログ\r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                String msg = strings.getProperty("favorite.remove.confirm");\r
@@ -288,7 +288,7 @@ public class ManageFavoriteDialog extends JDialog {
        protected void onRename() {\r
                PartsSet partsSet = (PartsSet) list.getSelectedValue();\r
                if (partsSet != null) {\r
-                       Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+                       Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                        .getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                        String localizedName = JOptionPane.showInputDialog(this, strings\r
index bcc72ec..a00d6fe 100644 (file)
@@ -87,7 +87,7 @@ public class MenuBuilder {
        public JMenuBar createMenuBar(MenuDataFactory[] menus) {\r
                \r
                // メニューリソース\r
-               Properties menuProps = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties menuProps = LocalizedResourcePropertyLoader.getCachedInstance()\r
                        .getLocalizedProperties(MENU_STRINGS_RESOURCE);\r
 \r
                // メニューバー\r
index 46e2887..508f9db 100644 (file)
@@ -110,7 +110,7 @@ public class PartsManageDialog extends JDialog {
                        }\r
                });\r
 \r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                setTitle(strings.getProperty("title"));\r
@@ -509,7 +509,7 @@ public class PartsManageDialog extends JDialog {
                        authors.add(row.getAuthor() == null ? "" : row.getAuthor());\r
                }\r
 \r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                if (authors.size() > 1) {\r
@@ -557,7 +557,7 @@ public class PartsManageDialog extends JDialog {
                        authors.add(row.getAuthor() == null ? "" : row.getAuthor());\r
                }\r
 \r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                if (authors.size() > 1) {\r
@@ -656,7 +656,7 @@ public class PartsManageDialog extends JDialog {
        }\r
        \r
        protected void onClose() {\r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(STRINGS_RESOURCE);\r
                if (JOptionPane.showConfirmDialog(this,\r
                                strings.getProperty("confirm.cancel"),\r
@@ -891,7 +891,7 @@ class PartsManageTableModel extends AbstractTableModelWithComboBoxModel<PartsMan
                        .getLogger(PartsManageTableModel.class.getName());\r
 \r
        private static Properties strings = LocalizedResourcePropertyLoader\r
-                       .getInstance().getLocalizedProperties(\r
+                       .getCachedInstance().getLocalizedProperties(\r
                                        PartsManageDialog.STRINGS_RESOURCE);\r
 \r
        /**\r
index 74b1154..0e33839 100644 (file)
@@ -232,7 +232,7 @@ public class PreviewPanel extends JPanel {
                setLayout(new BorderLayout());\r
 \r
                final AppConfig appConfig = AppConfig.getInstance();\r
-               final Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               final Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                        .getLocalizedProperties(STRINGS_RESOURCE);\r
                \r
                // 画像をロード中であることを示すインジケータの確認サイクル.\r
@@ -1808,7 +1808,7 @@ class PreviewControlPanel extends JPanel {
         * コンストラクタ\r
         */\r
        public PreviewControlPanel() {\r
-               final Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               final Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(STRINGS_RESOURCE);\r
                \r
                UIHelper uiHelper = UIHelper.getInstance();\r
index a447483..94c4680 100644 (file)
@@ -260,7 +260,7 @@ public class ProfileEditDialog extends JDialog {
                // 設定\r
                AppConfig appConfig = AppConfig.getInstance();\r
                final Properties strings = LocalizedResourcePropertyLoader\r
-                               .getInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
+                               .getCachedInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                // タイトル\r
                String title;\r
@@ -1214,7 +1214,7 @@ public class ProfileEditDialog extends JDialog {
                boolean writable = !original.isValid() || original.canWrite(); // 新規または更新可能\r
                if (writable) {\r
                        final Properties strings = LocalizedResourcePropertyLoader\r
-                                       .getInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
+                                       .getCachedInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
                        if (JOptionPane.showConfirmDialog(this, strings.get("confirm.close"), strings.getProperty("confirm"),\r
                                        JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.YES_OPTION) {\r
                                // YESでなければ継続しない.\r
@@ -1302,7 +1302,7 @@ public class ProfileEditDialog extends JDialog {
                // 編集可能であり、且つ、保存可能な状態であれば\r
                CharacterData newCd = createCharacterData(); \r
                final Properties strings = LocalizedResourcePropertyLoader\r
-                       .getInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
+                       .getCachedInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
                if (original.isValid() && !original.isSameStructure(newCd)) {\r
                        if (original.getRev().equals(newCd.getRev())) {\r
                                // 構造が変更されているがREVが変らない場合\r
@@ -1566,7 +1566,7 @@ class ColorGroupsTableModel extends AbstractTableModelWithComboBoxModel<ColorGro
 \r
        static {\r
                final Properties strings = LocalizedResourcePropertyLoader\r
-                               .getInstance().getLocalizedProperties(ProfileEditDialog.STRINGS_RESOURCE);\r
+                               .getCachedInstance().getLocalizedProperties(ProfileEditDialog.STRINGS_RESOURCE);\r
                colorGroupColumnNames = new String[] {\r
                                strings.getProperty("colorgroup.column.colorgroupname"),\r
                };\r
@@ -2032,7 +2032,7 @@ class CategoriesTableModel extends AbstractTableModelWithComboBoxModel<Categorie
        \r
        static {\r
                final Properties strings = LocalizedResourcePropertyLoader\r
-                               .getInstance().getLocalizedProperties(ProfileEditDialog.STRINGS_RESOURCE);\r
+                               .getCachedInstance().getLocalizedProperties(ProfileEditDialog.STRINGS_RESOURCE);\r
                categoriesColumnName = new String[] {\r
                                strings.getProperty("categories.column.categoryname"),\r
                                strings.getProperty("categories.column.multipleselectable"),\r
@@ -2322,7 +2322,7 @@ class LayersTableModel extends AbstractTableModelWithComboBoxModel<LayersTableRo
        \r
        static {\r
                final Properties strings = LocalizedResourcePropertyLoader\r
-                               .getInstance().getLocalizedProperties(ProfileEditDialog.STRINGS_RESOURCE);\r
+                               .getCachedInstance().getLocalizedProperties(ProfileEditDialog.STRINGS_RESOURCE);\r
                int columnsLen = Columns.values().length;\r
                layerColumnNames = new String[columnsLen];\r
                layersColumnWidths = new int[columnsLen];\r
@@ -2638,7 +2638,7 @@ class PartssetsTableModel extends AbstractTableModelWithComboBoxModel<PresetsTab
        \r
        static {\r
                final Properties strings = LocalizedResourcePropertyLoader\r
-                               .getInstance().getLocalizedProperties(ProfileEditDialog.STRINGS_RESOURCE);\r
+                               .getCachedInstance().getLocalizedProperties(ProfileEditDialog.STRINGS_RESOURCE);\r
                partssetsColumnNames = new String[] {\r
                                strings.getProperty("partssets.column.default"),\r
                                strings.getProperty("partssets.column.preset"),\r
@@ -2857,7 +2857,7 @@ class RecommendationTableModel extends AbstractTableModelWithComboBoxModel<Recom
        \r
        static {\r
                final Properties strings = LocalizedResourcePropertyLoader\r
-                               .getInstance().getLocalizedProperties(ProfileEditDialog.STRINGS_RESOURCE);\r
+                               .getCachedInstance().getLocalizedProperties(ProfileEditDialog.STRINGS_RESOURCE);\r
                partssetsColumnNames = new String[] {\r
                                strings.getProperty("recommendations.column.displayName"),\r
                                strings.getProperty("recommendations.column.url"),\r
index bcbf8f5..012cc20 100644 (file)
@@ -48,6 +48,7 @@ import javax.swing.JCheckBox;
 import javax.swing.JComboBox;\r
 import javax.swing.JComponent;\r
 import javax.swing.JDialog;\r
+import javax.swing.JFileChooser;\r
 import javax.swing.JFrame;\r
 import javax.swing.JLabel;\r
 import javax.swing.JList;\r
@@ -58,6 +59,7 @@ import javax.swing.JPopupMenu;
 import javax.swing.JRadioButton;\r
 import javax.swing.JRootPane;\r
 import javax.swing.JScrollPane;\r
+import javax.swing.JSeparator;\r
 import javax.swing.JSplitPane;\r
 import javax.swing.JTable;\r
 import javax.swing.JTextArea;\r
@@ -84,6 +86,7 @@ import charactermanaj.model.io.CharacterDataPersistent;
 import charactermanaj.model.io.PartsImageDirectoryWatchAgent;\r
 import charactermanaj.model.io.PartsImageDirectoryWatchAgentFactory;\r
 import charactermanaj.ui.util.FileDropTarget;\r
+import charactermanaj.ui.util.SingleRootFileSystemView;\r
 import charactermanaj.util.DesktopUtilities;\r
 import charactermanaj.util.ErrorMessageHelper;\r
 import charactermanaj.util.LocalizedResourcePropertyLoader;\r
@@ -121,8 +124,9 @@ public class ProfileSelectorDialog extends JDialog {
         */\r
        private SamplePicturePanel sampleImgPanel;\r
 \r
+       private Action actOK;\r
        \r
-       private JButton btnOK;\r
+       private Action actCancel;\r
        \r
        private Action actProfileNew;\r
 \r
@@ -138,6 +142,8 @@ public class ProfileSelectorDialog extends JDialog {
 \r
        private Action actProfileExport;\r
 \r
+       private Action actProfileTemplate;\r
+\r
        /**\r
         * プロファイル一覧を表示するリストコンポーネント\r
         */\r
@@ -185,7 +191,7 @@ public class ProfileSelectorDialog extends JDialog {
                });\r
                \r
                final Properties strings = LocalizedResourcePropertyLoader\r
-                               .getInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
+                               .getCachedInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                setTitle(strings.getProperty("title"));\r
 \r
@@ -248,6 +254,20 @@ public class ProfileSelectorDialog extends JDialog {
                                .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);\r
                pnlProfiles.add(characterListSP, BorderLayout.CENTER);\r
                \r
+               actOK = new AbstractAction(strings.getProperty("btn.select")) {\r
+                       private static final long serialVersionUID = 1L;\r
+                       public void actionPerformed(ActionEvent e) {\r
+                               onOK();\r
+                       }\r
+               };\r
+\r
+               actCancel = new AbstractAction(strings.getProperty("btn.cancel")) {\r
+                       private static final long serialVersionUID = 1L;\r
+                       public void actionPerformed(ActionEvent e) {\r
+                               onCancel();\r
+                       }\r
+               };\r
+\r
                actProfileNew = new AbstractAction(strings.getProperty("profile.new")) {\r
                        private static final long serialVersionUID = 1L;\r
                        public void actionPerformed(ActionEvent e) {\r
@@ -301,6 +321,43 @@ public class ProfileSelectorDialog extends JDialog {
                        }\r
                };\r
 \r
+               actProfileTemplate = new AbstractAction(\r
+                               strings.getProperty("profile.template")) {\r
+                       private static final long serialVersionUID = 1L;\r
+                       public void actionPerformed(ActionEvent e) {\r
+                               onProfileTemplate();\r
+                       }\r
+               };\r
+\r
+               final JPopupMenu popupTblMenu = new JPopupMenu();\r
+               popupTblMenu.add(new JMenuItem(actOK));\r
+               popupTblMenu.add(new JSeparator());\r
+               popupTblMenu.add(new JMenuItem(actProfileCopy));\r
+               popupTblMenu.add(new JMenuItem(actProfileEdit));\r
+               popupTblMenu.add(new JMenuItem(actProfileRemove));\r
+               popupTblMenu.add(new JSeparator());\r
+               popupTblMenu.add(new JMenuItem(actProfileBrowse));\r
+               popupTblMenu.add(new JMenuItem(actProfileImport));\r
+               popupTblMenu.add(new JMenuItem(actProfileExport));\r
+               popupTblMenu.add(new JSeparator());\r
+               popupTblMenu.add(new JMenuItem(actProfileTemplate));\r
+\r
+               characterList.addMouseListener(new MouseAdapter() {\r
+                       @Override\r
+                       public void mousePressed(MouseEvent e) {\r
+                               evaluatePopup(e);\r
+                       }\r
+                       @Override\r
+                       public void mouseReleased(MouseEvent e) {\r
+                               evaluatePopup(e);\r
+                       }\r
+                       private void evaluatePopup(MouseEvent e) {\r
+                               if (e.isPopupTrigger()) {\r
+                                       popupTblMenu.show(characterList, e.getX(), e.getY());\r
+                               }\r
+                       }\r
+               });\r
+\r
                JButton btnProfileNew = new JButton(actProfileNew);\r
                JButton btnProfileCopy = new JButton(actProfileCopy);\r
                JButton btnProfileEdit = new JButton(actProfileEdit);\r
@@ -308,6 +365,7 @@ public class ProfileSelectorDialog extends JDialog {
                JButton btnProfileBrowse = new JButton(actProfileBrowse);\r
                JButton btnProfileImport = new JButton(actProfileImport);\r
                JButton btnProfileExport = new JButton(actProfileExport);\r
+               JButton btnProfileTemplate = new JButton(actProfileTemplate);\r
                \r
                JPanel pnlProfileEditButtons = new JPanel();\r
                pnlProfileEditButtons.setLayout(new GridBagLayout());\r
@@ -357,6 +415,10 @@ public class ProfileSelectorDialog extends JDialog {
                gbc.gridy = 7;\r
                pnlProfileEditButtons.add(btnProfileExport, gbc);\r
 \r
+               gbc.gridx = 0;\r
+               gbc.gridy = 8;\r
+               pnlProfileEditButtons.add(btnProfileTemplate, gbc);\r
+\r
                JPanel pnlProfilesGroup = new JPanel(new BorderLayout());\r
                pnlProfilesGroup.setBorder(BorderFactory.createCompoundBorder(BorderFactory\r
                                .createEmptyBorder(3, 3, 3, 3), BorderFactory\r
@@ -461,20 +523,7 @@ public class ProfileSelectorDialog extends JDialog {
                btnPanel.setLayout(boxLayout);\r
                btnPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 42));\r
                \r
-               AbstractAction actOK = new AbstractAction(strings.getProperty("btn.select")) {\r
-                       private static final long serialVersionUID = 1L;\r
-                       public void actionPerformed(ActionEvent e) {\r
-                               onOK();\r
-                       }\r
-               };\r
-               AbstractAction actCancel = new AbstractAction(strings.getProperty("btn.cancel")) {\r
-                       private static final long serialVersionUID = 1L;\r
-                       public void actionPerformed(ActionEvent e) {\r
-                               onCancel();\r
-                       }\r
-               };\r
-               \r
-               btnOK = new JButton(actOK);\r
+               JButton btnOK = new JButton(actOK);\r
                JButton btnCancel = new JButton(actCancel);\r
                if (Main.isLinuxOrMacOSX()) {\r
                        btnPanel.add(btnCancel);\r
@@ -523,13 +572,13 @@ public class ProfileSelectorDialog extends JDialog {
                }\r
                \r
                final Properties strings = LocalizedResourcePropertyLoader\r
-                               .getInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
+                               .getCachedInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                boolean selected = (characterData != null);\r
                boolean enableEdit = (characterData != null)\r
                                && characterData.canWrite();\r
 \r
-               btnOK.setEnabled(selected);\r
+               actOK.setEnabled(selected);\r
        \r
                actProfileNew.setEnabled(true);\r
                actProfileCopy.setEnabled(selected);\r
@@ -538,6 +587,7 @@ public class ProfileSelectorDialog extends JDialog {
                actProfileImport.setEnabled(true);\r
                actProfileExport.setEnabled(selected);\r
                actProfileBrowse.setEnabled(selected);\r
+               actProfileTemplate.setEnabled(selected);\r
                \r
                if (enableEdit) {\r
                        actProfileEdit.putValue(Action.NAME,\r
@@ -782,7 +832,7 @@ public class ProfileSelectorDialog extends JDialog {
                if (makeDefault || cd == null) {\r
                        try {\r
                                final Properties strings = LocalizedResourcePropertyLoader\r
-                                               .getInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
+                                               .getCachedInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                                // キャラクターデータ選択用のコンボボックスの準備\r
                                JComboBox comboTemplates = new JComboBox();\r
@@ -795,7 +845,9 @@ public class ProfileSelectorDialog extends JDialog {
                                                        boolean cellHasFocus) {\r
                                                @SuppressWarnings("unchecked")\r
                                                Map.Entry<String, String> entry = (Map.Entry<String, String>) value;\r
-                                               lbl.setText(entry.getValue());\r
+                                               if (entry != null) {\r
+                                                       lbl.setText(entry.getValue());\r
+                                               }\r
                                                return lbl;\r
                                        }\r
                                });\r
@@ -915,7 +967,7 @@ public class ProfileSelectorDialog extends JDialog {
                }\r
                \r
                final Properties strings = LocalizedResourcePropertyLoader\r
-                               .getInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
+                               .getCachedInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                String msgTempl = strings.getProperty("profile.remove.confirm");\r
                MessageFormat fmt = new MessageFormat(msgTempl);\r
@@ -1006,7 +1058,7 @@ public class ProfileSelectorDialog extends JDialog {
                        // 選択したプロファイルを更新するか、新規にプロファイルを作成するか選択できるようにする\r
                        if (selCd != null) {\r
                                final Properties strings = LocalizedResourcePropertyLoader\r
-                                       .getInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
+                                       .getCachedInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                                JPanel radioPanel = new JPanel(new BorderLayout());\r
                                JRadioButton btnUpdate = new JRadioButton(strings.getProperty("importToUpdateProfile"));\r
@@ -1113,6 +1165,96 @@ public class ProfileSelectorDialog extends JDialog {
                        return;\r
                }\r
        }\r
+\r
+       /**\r
+        * 選択したプロファイルをテンプレートとして登録する.\r
+        */\r
+       protected void onProfileTemplate() {\r
+               try {\r
+                       CharacterData cd = null;\r
+                       int selRow = characterList.getSelectedRow();\r
+                       if (selRow >= 0) {\r
+                               cd = characterListModel.getRow(selRow);\r
+                       }\r
+                       if (cd == null || !cd.isValid()) {\r
+                               Toolkit tk = Toolkit.getDefaultToolkit();\r
+                               tk.beep();\r
+                               return;\r
+                       }\r
+\r
+                       String defualtName = cd.getId() + "_" + cd.getRev() + ".xml";\r
+                       // Windowsでのファイル名として使用禁止の文字を置換する.\r
+                       for (char c : "<>|:;*?/\\\"".toCharArray()) {\r
+                               defualtName = defualtName.replace(c, '_');\r
+                       }\r
+\r
+                       // カスタマイズ用テンプレートファイルの格納場所を取得する.\r
+                       final CharacterDataDefaultProvider defProv = new CharacterDataDefaultProvider();\r
+                       final File templDir = defProv.getTemplateDir(true);\r
+\r
+                       // 指定されたディレクトリ以外に表示・移動できないファイルシステムビューを使用したファイルチューザ\r
+                       JFileChooser fileChooser = new JFileChooser(\r
+                                       new SingleRootFileSystemView(templDir)) {\r
+                               private static final long serialVersionUID = 1L;\r
+\r
+                               @Override\r
+                               public void approveSelection() {\r
+                                       File outFile = getSelectedFile();\r
+                                       if (outFile == null) {\r
+                                               return;\r
+                                       }\r
+                                       String name = outFile.getName();\r
+                                       if (!defProv.canFileSave(name) || !name.endsWith(".xml")) {\r
+                                               // 書き込み不可ファイル、もしくはxml以外なので許可しない.\r
+                                               Toolkit tk = Toolkit.getDefaultToolkit();\r
+                                               tk.beep();\r
+                                               return;\r
+                                       }\r
+\r
+                                       // ファイルが存在すれば上書き確認する.\r
+                                       if (outFile.exists()) {\r
+                                               Properties strings = LocalizedResourcePropertyLoader\r
+                                                               .getCachedInstance().getLocalizedProperties(\r
+                                                                               STRINGS_RESOURCE);\r
+\r
+                                               if (JOptionPane.showConfirmDialog(this,\r
+                                                               strings.getProperty("confirmOverwrite"),\r
+                                                               strings.getProperty("confirm"),\r
+                                                               JOptionPane.YES_NO_OPTION,\r
+                                                               JOptionPane.WARNING_MESSAGE) != JOptionPane.YES_OPTION) {\r
+                                                       return;\r
+                                               }\r
+                                       }\r
+\r
+                                       super.approveSelection();\r
+                               }\r
+                       };\r
+\r
+                       // 保存先ファイル名\r
+                       fileChooser.setSelectedFile(new File(templDir, defualtName));\r
+                       int ret = fileChooser.showSaveDialog(this);\r
+                       if (ret != JFileChooser.APPROVE_OPTION) {\r
+                               return;\r
+                       }\r
+\r
+                       // テンプレート名\r
+                       String localizedName = cd.getName();\r
+                       final Properties strings = LocalizedResourcePropertyLoader\r
+                                       .getCachedInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
+                       localizedName = JOptionPane.showInputDialog(this,\r
+                                       strings.getProperty("inputTemplateName"), localizedName);\r
+                       if (localizedName == null) {\r
+                               return;\r
+                       }\r
+\r
+                       File outFile = fileChooser.getSelectedFile();\r
+                       defProv.saveTemplate(outFile.getName(), cd, localizedName);\r
+\r
+               } catch (Exception ex) {\r
+                       ErrorMessageHelper.showErrorDialog(this, ex);\r
+                       return;\r
+               }\r
+       }\r
 }\r
 \r
 /**\r
@@ -1185,7 +1327,7 @@ class ProfileSelectorTableModel extends AbstractTableModel {
                                return;\r
                        }\r
                        final Properties strings = LocalizedResourcePropertyLoader\r
-                                       .getInstance().getLocalizedProperties(\r
+                                       .getCachedInstance().getLocalizedProperties(\r
                                                        ProfileSelectorDialog.STRINGS_RESOURCE);\r
                        displayName = strings.getProperty(columnName);\r
                        width = Integer\r
index d229d9b..3f93329 100644 (file)
@@ -192,7 +192,7 @@ public class SamplePicturePanel extends JPanel {
                        Container parent = getParent();\r
                        if (parent != null && parent instanceof JViewport) {\r
                                Properties strings = LocalizedResourcePropertyLoader\r
-                                               .getInstance().getLocalizedProperties("languages/samplepicturepanel");\r
+                                               .getCachedInstance().getLocalizedProperties("languages/samplepicturepanel");\r
                                if (!fullsize) {\r
                                        tooltip = strings.getProperty("dblclick.fullsize");\r
                                } else {\r
index 856edd8..9dec58a 100644 (file)
@@ -110,7 +110,7 @@ public class SearchPartsDialog extends JDialog {
                });\r
                \r
                \r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                setTitle(strings.getProperty("title"));\r
@@ -446,7 +446,7 @@ class SearchPartsTableModel extends AbstractTableModelWithComboBoxModel<Map.Entr
        private static final int[] COLUMN_WIDTHS;\r
        \r
        static {\r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(SearchPartsDialog.STRINGS_RESOURCE);\r
                \r
                COLUMN_NAMES = new String[] {\r
index 219b92e..697ae2d 100644 (file)
@@ -137,7 +137,7 @@ public class SelectCharatersDirDialog extends JDialog {
        }\r
        \r
        private void initComponent() {\r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                        .getLocalizedProperties("languages/selectCharatersDirDialog");\r
                \r
                Container contentPane = getContentPane();\r
index d56718e..e4c1d71 100644 (file)
@@ -178,7 +178,7 @@ public class UkagakaConvertDialog extends JDialog {
         */\r
        private void initComponent() {\r
                \r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                        .getLocalizedProperties(STRINGS_RESOURCE);\r
 \r
                setTitle(strings.getProperty("title"));\r
index 1dcffa6..25175ed 100644 (file)
@@ -152,7 +152,7 @@ public class WallpaperDialog extends JDialog {
         * このダイアログのコンポーネントを初期化します.<br>\r
         */\r
        private void initComponent() {\r
-               Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                        .getLocalizedProperties(WallpaperDialog.STRINGS_RESOURCE);\r
 \r
                setTitle(strings.getProperty("title"));\r
@@ -532,7 +532,7 @@ public class WallpaperDialog extends JDialog {
                }\r
                \r
                if (messageid != null) {\r
-                       Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+                       Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
                                .getLocalizedProperties(WallpaperDialog.STRINGS_RESOURCE);\r
 \r
                        String message = strings.getProperty(messageid);\r
index b4bfc55..d88856b 100644 (file)
@@ -76,7 +76,7 @@ public class PredefinedWallpaper implements Comparable<PredefinedWallpaper>, Loc
         * @return 定義済み壁紙リソースリスト\r
         */\r
        public static List<PredefinedWallpaper> getPredefinedWallpapers() {\r
-               Properties predefinedWallpapers = LocalizedResourcePropertyLoader.getInstance()\r
+               Properties predefinedWallpapers = LocalizedResourcePropertyLoader.getCachedInstance()\r
                        .getLocalizedProperties(PREDEFINED_WALLPAPER_RESOURCE);\r
 \r
                ArrayList<PredefinedWallpaper> results = new ArrayList<PredefinedWallpaper>();\r
diff --git a/src/charactermanaj/ui/util/SingleRootFileSystemView.java b/src/charactermanaj/ui/util/SingleRootFileSystemView.java
new file mode 100644 (file)
index 0000000..e334d5a
--- /dev/null
@@ -0,0 +1,45 @@
+package charactermanaj.ui.util;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+\r
+import javax.swing.filechooser.FileSystemView;\r
+\r
+/**\r
+ * ファイルチューザのコンストラクタに指定することで、特定のディレクトリ以外に移動できないようにする<br>\r
+ * ためのファイルシステムビューを構築します.<br>\r
+ * 親ディレクトリへの移動、別のルートディレクトリの選択はできず、新規ディレクトリの作成もできません.<br>\r
+ * \r
+ * @author seraphy\r
+ */\r
+public class SingleRootFileSystemView extends FileSystemView {\r
+\r
+       /**\r
+        * 対象ディレクトリ\r
+        */\r
+       private File dir;\r
+\r
+       public SingleRootFileSystemView(File templDir) {\r
+               if (templDir == null) {\r
+                       throw new IllegalArgumentException();\r
+               }\r
+               this.dir = templDir;\r
+       }\r
+\r
+       @Override\r
+       public File createNewFolder(File containingDir) throws IOException {\r
+               return null;\r
+       }\r
+       @Override\r
+       public File getDefaultDirectory() {\r
+               return dir;\r
+       }\r
+       @Override\r
+       public File getHomeDirectory() {\r
+               return dir;\r
+       }\r
+       @Override\r
+       public File[] getRoots() {\r
+               return new File[]{dir};\r
+       }\r
+}\r
index af7378e..6f32b71 100644 (file)
@@ -4,45 +4,54 @@ import java.io.InputStream;
 import java.net.URL;\r
 import java.util.HashMap;\r
 import java.util.Locale;\r
+import java.util.Map;\r
 import java.util.Properties;\r
 \r
 /**\r
  * xml形式のリソース上のプロパティファイルのローカライズされた読み込みを行うためのクラス.<br>\r
  * リソースは、単純名、言語名を末尾に付与したもの、言語名と国を末尾に付与したもの、言語名と国とバリアントを末尾に付与したもの、の順で読み取られる.<br>\r
  * 順番に読み込んで重ね合わせる.<br>\r
- * ä¸\80度読ã\81¿è¾¼ã\82\93ã\81 ã\82\82ã\81®ã\81¯ã\82­ã\83£ã\83\83ã\82·ã\83¥ã\81\95ã\82\8c次å\9b\9e以é\99\8dã\81¯èª­ã\81¿å\8f\96ã\82\89ã\82\8cã\81ªã\81\84.<br>\r
+ * ä¸\80度読ã\81¿è¾¼ã\82\93ã\81 ã\82\82ã\81®ã\81¯ã\82­ã\83£ã\83\83ã\82·ã\83¥ã\81«ä¿\9då­\98ã\81\95ã\82\8c次å\9b\9e以é\99\8dã\81¯ã\80\81ã\81\9dã\82\8cã\81\8cç\94¨ã\81\84ã\82\89ã\82\8cã\82\8b.<br>\r
  */\r
 public class LocalizedResourcePropertyLoader extends ResourceLoader {\r
        \r
        /**\r
         * プロパティファイル群と、それに対するキャッシュ\r
         */\r
-       private HashMap<ResourceNames, Properties> propCache = new HashMap<ResourceNames, Properties>();\r
+       private Map<ResourceNames, Properties> propCache;\r
        \r
        /**\r
-        * ã\82·ã\83³ã\82°ã\83«ã\83\88ã\83³ã\82¤ã\83³ã\82¹ã\82¿ã\83³ã\82¹\r
+        * ã\82­ã\83£ã\83\83ã\82·ã\83¥ã\82\92å\85±æ\9c\89ã\81\99ã\82\8bã\82·ã\83³ã\82°ã\83«ã\83\88ã\83³ã\82¤ã\83³ã\82¹ã\82¿ã\83³ã\82¹.\r
         */\r
-       private static final LocalizedResourcePropertyLoader inst = new LocalizedResourcePropertyLoader();\r
+       private static final LocalizedResourcePropertyLoader inst = new LocalizedResourcePropertyLoader(\r
+                       new HashMap<ResourceNames, Properties>());\r
        \r
        /**\r
-        * プライベートコンストラクタ\r
+        * 独立したキャッシュを指定することのできるコンストラクタ.<br>\r
+        * \r
+        * @param propCache\r
+        *            キャッシュ、不要であればnull可\r
         */\r
-       private LocalizedResourcePropertyLoader() {\r
-               super();\r
+       public LocalizedResourcePropertyLoader(\r
+                       Map<ResourceNames, Properties> propCache) {\r
+               this.propCache = propCache;\r
        }\r
        \r
        /**\r
         * インスタンスを取得する\r
+        * \r
         * @return インスタンス\r
         */\r
-       public static LocalizedResourcePropertyLoader getInstance() {\r
+       public static LocalizedResourcePropertyLoader getCachedInstance() {\r
                return inst;\r
        }\r
        \r
        /**\r
         * リソース名を指定してデフォルトのロケールでローカライズされたリソースプロパティを読み込む.<br>\r
         * リソースはxml形式である。リソース名には.xmlを付与しない.(自動的に内部で付与される.)\r
-        * @param name リソース名\r
+        * \r
+        * @param name\r
+        *            リソース名\r
         * @return プロパティ\r
         */\r
        public Properties getLocalizedProperties(String name) {\r
@@ -52,11 +61,30 @@ public class LocalizedResourcePropertyLoader extends ResourceLoader {
        /**\r
         * リソース名を指定して指定したロケールでローカライズされたリソースプロパティを読み込む.<br>\r
         * リソースはxml形式である。リソース名には.xmlを付与しない.(自動的に内部で付与される.)\r
-        * @param name リソース名\r
-        * @param locale ロケール、nullの場合はデフォルトのロケール\r
+        * \r
+        * @param name\r
+        *            リソース名\r
+        * @param locale\r
+        *            ロケール、nullの場合はデフォルトのロケール\r
         * @return プロパティ\r
         */\r
        public Properties getLocalizedProperties(String name, Locale locale) {\r
+               return getProperties(getResourceNames(name, locale));\r
+       }\r
+\r
+       /**\r
+        * リソース名を指定して指定したロケールでローカライズされたリソースプロパティの一覧を取得する.<br>\r
+        * リソースはxml形式である。リソース名には.xmlを付与しない.(自動的に内部で付与される.)<br>\r
+        * 返される順序は、読み込み順となる。(順番に読み込んで上書きしてゆくことを想定する).<br>\r
+        * ロケール中立のものが先頭となり、指定したロケールにもっとも一致するものが最後となる.<br>\r
+        * \r
+        * @param name\r
+        *            リソース名\r
+        * @param locale\r
+        *            ロケール、nullの場合はデフォルトのロケール\r
+        * @return プロパティリソースの一覧(読み込み順)\r
+        */\r
+       public static ResourceNames getResourceNames(String name, Locale locale) {\r
                if (name == null || name.length() == 0) {\r
                        throw new IllegalArgumentException();\r
                }\r
@@ -74,28 +102,34 @@ public class LocalizedResourcePropertyLoader extends ResourceLoader {
                        name + "_" + language + "_" + country + ".xml",\r
                        name + "_" + language + "_" + country + "_" + variant + ".xml",\r
                };\r
-\r
-               return getProperties(new ResourceNames(resourceNames));\r
+               return new ResourceNames(resourceNames);\r
        }\r
 \r
        /**\r
         * リソース名群をもとにキャッシュもしくはプロパティをロードして返す.<br>\r
         * キャッシュされていない場合はプロパティをロードして、それをキャッシュに格納する.<br>\r
+        * (共有キャッシュ時、もしくは独自のキャッシュが指定されている場合).<br>\r
         * リソースが一つも存在しない場合は実行時例外を発生させる.<br>\r
-        * @param resourceNames リソース名群\r
+        * \r
+        * @param resourceNames\r
+        *            リソース名群\r
         * @return プロパティ\r
         */\r
-       protected Properties getProperties(ResourceNames resourceNames) {\r
+       public Properties getProperties(ResourceNames resourceNames) {\r
                if (resourceNames == null) {\r
                        throw new IllegalArgumentException();\r
                }\r
                Properties prop;\r
-               synchronized (propCache) {\r
-                       prop = propCache.get(resourceNames);\r
-                       if (prop == null) {\r
-                               prop = loadProperties(resourceNames);\r
-                               propCache.put(resourceNames, prop);\r
+               if (propCache != null) {\r
+                       synchronized (propCache) {\r
+                               prop = propCache.get(resourceNames);\r
+                               if (prop == null) {\r
+                                       prop = loadProperties(resourceNames);\r
+                                       propCache.put(resourceNames, prop);\r
+                               }\r
                        }\r
+               } else {\r
+                       prop = loadProperties(resourceNames);\r
                }\r
                if (prop == null) {\r
                        throw new RuntimeException("missing resource: " + resourceNames);\r
@@ -106,7 +140,9 @@ public class LocalizedResourcePropertyLoader extends ResourceLoader {
        /**\r
         * リソース名群からリソースプロパティをロードして返す.<br>\r
         * 一つも存在しない場合はnullを返す.<br>\r
-        * @param resourceNames リソース群名\r
+        * \r
+        * @param resourceNames\r
+        *            リソース群名\r
         * @return プロパティ\r
         */\r
        protected Properties loadProperties(ResourceNames resourceNames) {\r
index dec1975..bcc074d 100644 (file)
@@ -11,26 +11,29 @@ import java.security.PrivilegedExceptionAction;
 \r
 /**\r
  * リソースをロードするための抽象基底クラス.\r
+ * \r
  * @author seraphy\r
  */\r
-public abstract class ResourceLoader {\r
+public class ResourceLoader {\r
 \r
        /**\r
         * クラスローダを取得する.<br>\r
         * まずローカルファイル上のリソースディレクトリがあれば、それを検索する.<br>\r
         * つぎにスレッドに関連づけられているコンテキストクラスローダか、もしなければ、このクラスをロードしたクラスローダを用いて検索する.<br>\r
+        * \r
         * @return クラスローダ\r
         */\r
-       protected ClassLoader getClassLoader() {\r
+       public ClassLoader getClassLoader() {\r
                return getLocalizedClassLoader(getDefaultClassLoader());\r
        }\r
        \r
        /**\r
         * クラスローダを取得する.<br>\r
         * スレッドに関連づけられているコンテキストクラスローダか、もしなければ、このクラスをロードしたクラスローダを返す.<br>\r
+        * \r
         * @return クラスローダ\r
         */\r
-       protected ClassLoader getDefaultClassLoader() {\r
+       public ClassLoader getDefaultClassLoader() {\r
                return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {\r
                        public ClassLoader run() {\r
                                ClassLoader cl = Thread.currentThread().getContextClassLoader();\r
@@ -46,10 +49,12 @@ public abstract class ResourceLoader {
         * ローカルファイル上のリソースディレクトリにアクセスするクラスローダ取得する.<br>\r
         * 作成されていなければparentをそのまま返す.<br>\r
         * リソースはローカルファイル上のパスで検索されたのちにparentで検索されます.(標準のURLClassLoaderとは違う探索方法)<br>\r
-        * @param parent 親クラスローダ、nullの場合は親の探索をしない.\r
+        * \r
+        * @param parent\r
+        *            親クラスローダ、nullの場合は親の探索をしない.\r
         * @return ローカルシステム上のリソースディレクトリにアクセスするクラスローダ、なければparentのまま\r
         */\r
-       protected ClassLoader getLocalizedClassLoader(final ClassLoader parent) {\r
+       public ClassLoader getLocalizedClassLoader(final ClassLoader parent) {\r
                try {\r
                        File baseDir = ConfigurationDirUtilities.getUserDataDir();\r
                        SetupLocalization localize = new SetupLocalization(baseDir);\r
@@ -63,7 +68,7 @@ public abstract class ResourceLoader {
                                        return new URLClassLoader(urls, parent) {\r
                                                @Override\r
                                                public URL getResource(String name) {\r
-                                                       URL url = findResource(name); // 子が優先 (標準と逆)\r
+                                                                       URL url = findResource(name); // 子が優先 (標準と逆)\r
                                                        if (url == null) {\r
                                                                ClassLoader parent = getParent();\r
                                                                if (parent != null) {\r
@@ -87,10 +92,12 @@ public abstract class ResourceLoader {
         * クラスローダによりリソースをロードする.<br>\r
         * 該当するリソースが存在しない場合はnullを返す.<br>\r
         * リソース名がnullの場合もnullを返す.<br>\r
-        * @param name リソース名またはnull\r
+        * \r
+        * @param name\r
+        *            リソース名またはnull\r
         * @return リソースがあれば、そのURL。なければnull\r
         */\r
-       protected URL getResource(String name) {\r
+       public URL getResource(String name) {\r
                if (name == null) {\r
                        return null;\r
                }\r
index 64e00f9..5557872 100644 (file)
@@ -5,9 +5,10 @@ import java.util.Arrays;
 \r
 /**\r
  * 関連もしくは類似するリソースをまとめて取り扱うためにグループ化するためのクラス.<br>\r
+ * \r
  * @author seraphy\r
  */\r
-final class ResourceNames extends AbstractList<String> {\r
+public class ResourceNames extends AbstractList<String> {\r
        \r
        private final String[] resourceNames;\r
        \r
index af16b45..1cb0f1a 100644 (file)
@@ -11,6 +11,7 @@ import java.net.URL;
 import java.net.URLConnection;\r
 import java.util.ArrayList;\r
 import java.util.Collection;\r
+import java.util.EnumSet;\r
 import java.util.Enumeration;\r
 import java.util.jar.JarEntry;\r
 import java.util.jar.JarFile;\r
@@ -28,6 +29,28 @@ public class SetupLocalization extends ResourceLoader {
        \r
        public static final String DIRNAME_RESOURCES = "resources";\r
 \r
+       /**\r
+        * リソースフォルダ下のサブディレクトリ一覧.<br>\r
+        */\r
+       public enum Resources {\r
+               Languages("languages"), Menu("menu"), Template("template");\r
+\r
+               private final String dirName;\r
+\r
+               private Resources(String dirName) {\r
+                       this.dirName = dirName;\r
+               }\r
+\r
+               public String getDirName() {\r
+                       return dirName;\r
+               }\r
+\r
+               @Override\r
+               public String toString() {\r
+                       return getDirName();\r
+               }\r
+       }\r
+\r
        private File baseDir;\r
        \r
        /**\r
@@ -46,19 +69,23 @@ public class SetupLocalization extends ResourceLoader {
        /**\r
         * コピー対象とするリソース一覧を取得する.<br>\r
         * \r
+        * @param resourceSet\r
+        *            リソースディレクトリのサブディレクトリ名のリスト\r
         * @return リソース一覧(言語関連リソース、テンプレートなど)\r
         * @throws IOException\r
         *             失敗\r
         */\r
-       protected Collection<String> getResourceList() throws IOException {\r
+       protected Collection<String> getResourceList(EnumSet<Resources> resourceSet)\r
+                       throws IOException {\r
+               if (resourceSet == null) {\r
+                       resourceSet = EnumSet.noneOf(Resources.class);\r
+               }\r
                ArrayList<String> resources = new ArrayList<String>();\r
 \r
-               // リソースとしてコピー対象とするパッケージ名\r
-               String[] names = new String[]{"languages", "menu", "template"};\r
-\r
                ClassLoader cl = getClass().getClassLoader();\r
 \r
-               for (String name : names) {\r
+               for (Resources resourceKey : resourceSet) {\r
+                       String name = resourceKey.getDirName();\r
                        URL loc = cl.getResource(name);\r
                        if (loc == null) {\r
                                continue;\r
@@ -174,17 +201,25 @@ public class SetupLocalization extends ResourceLoader {
        /**\r
         * ローカルシステム上のアプリケーションデータディレクトリに言語リソースをコピーする.\r
         * \r
+        * @param resourceSet\r
+        *            コピーするリソースセット.\r
+        * @param overwrite\r
+        *            上書きを許可する場合はtrue、スキップする場合はfalse\r
         * @throws IOException\r
         *             失敗\r
         */\r
-       public void setupToLocal() throws IOException {\r
+       public void setupToLocal(EnumSet<Resources> resourceSet, boolean overwrite)\r
+                       throws IOException {\r
                File toDir = getResourceDir();\r
                ClassLoader cl = getDefaultClassLoader();\r
-               for (String resourceName : getResourceList()) {\r
+               for (String resourceName : getResourceList(resourceSet)) {\r
                        URL url = cl.getResource(resourceName);\r
                        if (url != null) {\r
                                File toFile = new File(toDir, resourceName).getCanonicalFile();\r
-                               copyResource(url, toFile);\r
+                               if (overwrite || !toFile.exists()) {\r
+                                       // 上書き許可か、まだファイルが存在しなければコピーする.\r
+                                       copyResource(url, toFile);\r
+                               }\r
 \r
                        } else {\r
                                logger.log(Level.WARNING, "missing resource: " + resourceName);\r