<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
<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
<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
<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
\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
\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
* コンストラクタ\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
}\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
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
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
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
* @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
}\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
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
\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
* ローカライズリソースをユーザディレクトリ上に展開する.\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
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
\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
return;\r
}\r
\r
- Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+ Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
.getLocalizedProperties("languages/appconfigdialog");\r
\r
// 編集されたプロパティを取得する.\r
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
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
}\r
}\r
\r
- Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+ Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
.getLocalizedProperties(STRINGS_RESOURCE);\r
\r
if (writeMode && file.exists()) {\r
}\r
this.colorKey = colorKey;\r
\r
- Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+ Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
.getLocalizedProperties(STRINGS_RESOURCE);\r
\r
colorDisplayPanel = createColorDiaplyPanel();\r
}\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
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
}\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
}\r
});\r
\r
- Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+ Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
.getLocalizedProperties(STRINGS_RESOURCE);\r
\r
// タイトル\r
}\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
}\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
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
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
\r
setName("presetSelectPanel");\r
\r
- Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+ Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
.getLocalizedProperties(ExportWizardDialog.STRINGS_RESOURCE);\r
\r
setName("choosePartsPanel");\r
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
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
\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
}\r
});\r
\r
- Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+ Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
.getLocalizedProperties(STRINGS_RESOURCE);\r
\r
// タイトル\r
}\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
* インポートの実行.<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
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
return null;\r
}\r
\r
- Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+ Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
.getLocalizedProperties(ImportWizardDialog.STRINGS_RESOURCE);\r
\r
URI importArchive;\r
/* 以下、選択結果 */\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
return;\r
}\r
\r
- Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+ Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
.getLocalizedProperties(ImportWizardDialog.STRINGS_RESOURCE);\r
\r
// 呼び出しもと情報\r
\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
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
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
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
});\r
\r
final Properties strings = LocalizedResourcePropertyLoader\r
- .getInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
+ .getCachedInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
\r
setTitle(strings.getProperty("title"));\r
\r
\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
\r
// 設定まわり準備\r
AppConfig appConfig = AppConfig.getInstance();\r
- Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+ Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
.getLocalizedProperties(STRINGS_RESOURCE);\r
\r
// タイトル表示\r
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
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
}\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
return;\r
}\r
\r
- Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+ Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
.getLocalizedProperties(STRINGS_RESOURCE);\r
\r
// お気に入りに登録するパーツセットが最後に使用したお気に入りと同じ構成であれば、\r
*/\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
});\r
\r
Properties strings = LocalizedResourcePropertyLoader\r
- .getInstance()\r
+ .getCachedInstance()\r
.getLocalizedProperties(STRINGS_RESOURCE);\r
\r
setTitle(strings.getProperty("manageFavorites"));\r
*/\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
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
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
}\r
});\r
\r
- Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+ Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
.getLocalizedProperties(STRINGS_RESOURCE);\r
\r
setTitle(strings.getProperty("title"));\r
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
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
}\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
.getLogger(PartsManageTableModel.class.getName());\r
\r
private static Properties strings = LocalizedResourcePropertyLoader\r
- .getInstance().getLocalizedProperties(\r
+ .getCachedInstance().getLocalizedProperties(\r
PartsManageDialog.STRINGS_RESOURCE);\r
\r
/**\r
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
* コンストラクタ\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
// 設定\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
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
// 編集可能であり、且つ、保存可能な状態であれば\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
\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
\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
\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
\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
\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
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
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
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
*/\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
\r
private Action actProfileExport;\r
\r
+ private Action actProfileTemplate;\r
+\r
/**\r
* プロファイル一覧を表示するリストコンポーネント\r
*/\r
});\r
\r
final Properties strings = LocalizedResourcePropertyLoader\r
- .getInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
+ .getCachedInstance().getLocalizedProperties(STRINGS_RESOURCE);\r
\r
setTitle(strings.getProperty("title"));\r
\r
.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
}\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
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
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
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
}\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
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
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
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
}\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
// 選択したプロファイルを更新するか、新規にプロファイルを作成するか選択できるようにする\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
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
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
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
});\r
\r
\r
- Properties strings = LocalizedResourcePropertyLoader.getInstance()\r
+ Properties strings = LocalizedResourcePropertyLoader.getCachedInstance()\r
.getLocalizedProperties(STRINGS_RESOURCE);\r
\r
setTitle(strings.getProperty("title"));\r
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
}\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
*/\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
* このダイアログのコンポーネントを初期化します.<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
}\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
* @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
--- /dev/null
+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
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
/**\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
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
/**\r
* リソース名群からリソースプロパティをロードして返す.<br>\r
* 一つも存在しない場合はnullを返す.<br>\r
- * @param resourceNames リソース群名\r
+ * \r
+ * @param resourceNames\r
+ * リソース群名\r
* @return プロパティ\r
*/\r
protected Properties loadProperties(ResourceNames resourceNames) {\r
\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
* ローカルファイル上のリソースディレクトリにアクセスするクラスローダ取得する.<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
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
* クラスローダによりリソースをロードする.<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
\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
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
\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
/**\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
/**\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