From: seraphy
Date: Sun, 20 Feb 2011 18:11:54 +0000 (+0000)
Subject: ver0.95リリース 2011/02/21
X-Git-Tag: ver0.95
X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=refs%2Ftags%2Fver0.95;p=charactermanaj%2FCharacterManaJ.git
ver0.95リリース 2011/02/21
git-svn-id: https://svn.sourceforge.jp/svnroot/charactermanaj/tags/ver0_95@9 5b6e9025-a2e8-4882-b233-f889982098c5
---
diff --git a/.fbprefs b/.fbprefs
new file mode 100644
index 0000000..69980f7
--- /dev/null
+++ b/.fbprefs
@@ -0,0 +1,127 @@
+#FindBugs User Preferences
+#Sun Feb 20 00:21:29 JST 2011
+detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true
+detectorBadAppletConstructor=BadAppletConstructor|false
+detectorBadResultSetAccess=BadResultSetAccess|true
+detectorBadSyntaxForRegularExpression=BadSyntaxForRegularExpression|true
+detectorBadUseOfReturnValue=BadUseOfReturnValue|true
+detectorBadlyOverriddenAdapter=BadlyOverriddenAdapter|true
+detectorBooleanReturnNull=BooleanReturnNull|true
+detectorCallToUnsupportedMethod=CallToUnsupportedMethod|false
+detectorCheckImmutableAnnotation=CheckImmutableAnnotation|true
+detectorCheckTypeQualifiers=CheckTypeQualifiers|true
+detectorCloneIdiom=CloneIdiom|true
+detectorComparatorIdiom=ComparatorIdiom|true
+detectorConfusedInheritance=ConfusedInheritance|true
+detectorConfusionBetweenInheritedAndOuterMethod=ConfusionBetweenInheritedAndOuterMethod|true
+detectorCrossSiteScripting=CrossSiteScripting|true
+detectorDoInsideDoPrivileged=DoInsideDoPrivileged|true
+detectorDontCatchIllegalMonitorStateException=DontCatchIllegalMonitorStateException|true
+detectorDontIgnoreResultOfPutIfAbsent=DontIgnoreResultOfPutIfAbsent|true
+detectorDontUseEnum=DontUseEnum|true
+detectorDroppedException=DroppedException|true
+detectorDumbMethodInvocations=DumbMethodInvocations|true
+detectorDumbMethods=DumbMethods|true
+detectorDuplicateBranches=DuplicateBranches|true
+detectorEmptyZipFileEntry=EmptyZipFileEntry|true
+detectorEqualsOperandShouldHaveClassCompatibleWithThis=EqualsOperandShouldHaveClassCompatibleWithThis|true
+detectorFinalizerNullsFields=FinalizerNullsFields|true
+detectorFindBadCast2=FindBadCast2|true
+detectorFindBadForLoop=FindBadForLoop|true
+detectorFindCircularDependencies=FindCircularDependencies|false
+detectorFindDeadLocalStores=FindDeadLocalStores|true
+detectorFindDoubleCheck=FindDoubleCheck|true
+detectorFindEmptySynchronizedBlock=FindEmptySynchronizedBlock|true
+detectorFindFieldSelfAssignment=FindFieldSelfAssignment|true
+detectorFindFinalizeInvocations=FindFinalizeInvocations|true
+detectorFindFloatEquality=FindFloatEquality|true
+detectorFindHEmismatch=FindHEmismatch|true
+detectorFindInconsistentSync2=FindInconsistentSync2|true
+detectorFindJSR166LockMonitorenter=FindJSR166LockMonitorenter|true
+detectorFindLocalSelfAssignment2=FindLocalSelfAssignment2|true
+detectorFindMaskedFields=FindMaskedFields|true
+detectorFindMismatchedWaitOrNotify=FindMismatchedWaitOrNotify|true
+detectorFindNakedNotify=FindNakedNotify|true
+detectorFindNonSerializableStoreIntoSession=FindNonSerializableStoreIntoSession|true
+detectorFindNonSerializableValuePassedToWriteObject=FindNonSerializableValuePassedToWriteObject|true
+detectorFindNonShortCircuit=FindNonShortCircuit|true
+detectorFindNullDeref=FindNullDeref|true
+detectorFindNullDerefsInvolvingNonShortCircuitEvaluation=FindNullDerefsInvolvingNonShortCircuitEvaluation|true
+detectorFindOpenStream=FindOpenStream|true
+detectorFindPuzzlers=FindPuzzlers|true
+detectorFindRefComparison=FindRefComparison|true
+detectorFindReturnRef=FindReturnRef|true
+detectorFindRunInvocations=FindRunInvocations|true
+detectorFindSelfComparison=FindSelfComparison|true
+detectorFindSelfComparison2=FindSelfComparison2|true
+detectorFindSleepWithLockHeld=FindSleepWithLockHeld|true
+detectorFindSpinLoop=FindSpinLoop|true
+detectorFindSqlInjection=FindSqlInjection|true
+detectorFindTwoLockWait=FindTwoLockWait|true
+detectorFindUncalledPrivateMethods=FindUncalledPrivateMethods|true
+detectorFindUnconditionalWait=FindUnconditionalWait|true
+detectorFindUninitializedGet=FindUninitializedGet|true
+detectorFindUnrelatedTypesInGenericContainer=FindUnrelatedTypesInGenericContainer|true
+detectorFindUnreleasedLock=FindUnreleasedLock|true
+detectorFindUnsatisfiedObligation=FindUnsatisfiedObligation|true
+detectorFindUnsyncGet=FindUnsyncGet|true
+detectorFindUselessControlFlow=FindUselessControlFlow|true
+detectorFormatStringChecker=FormatStringChecker|true
+detectorHugeSharedStringConstants=HugeSharedStringConstants|true
+detectorIDivResultCastToDouble=IDivResultCastToDouble|true
+detectorIncompatMask=IncompatMask|true
+detectorInconsistentAnnotations=InconsistentAnnotations|true
+detectorInefficientMemberAccess=InefficientMemberAccess|false
+detectorInefficientToArray=InefficientToArray|true
+detectorInfiniteLoop=InfiniteLoop|true
+detectorInfiniteRecursiveLoop=InfiniteRecursiveLoop|true
+detectorInfiniteRecursiveLoop2=InfiniteRecursiveLoop2|false
+detectorInheritanceUnsafeGetResource=InheritanceUnsafeGetResource|true
+detectorInitializationChain=InitializationChain|true
+detectorInstantiateStaticClass=InstantiateStaticClass|true
+detectorInvalidJUnitTest=InvalidJUnitTest|true
+detectorIteratorIdioms=IteratorIdioms|true
+detectorLazyInit=LazyInit|true
+detectorLoadOfKnownNullValue=LoadOfKnownNullValue|true
+detectorLostLoggerDueToWeakReference=LostLoggerDueToWeakReference|true
+detectorMethodReturnCheck=MethodReturnCheck|true
+detectorMultithreadedInstanceAccess=MultithreadedInstanceAccess|true
+detectorMutableLock=MutableLock|true
+detectorMutableStaticFields=MutableStaticFields|true
+detectorNaming=Naming|true
+detectorNumberConstructor=NumberConstructor|true
+detectorOverridingEqualsNotSymmetrical=OverridingEqualsNotSymmetrical|true
+detectorPreferZeroLengthArrays=PreferZeroLengthArrays|true
+detectorPublicSemaphores=PublicSemaphores|false
+detectorQuestionableBooleanAssignment=QuestionableBooleanAssignment|true
+detectorReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass=ReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass|true
+detectorReadReturnShouldBeChecked=ReadReturnShouldBeChecked|true
+detectorRedundantInterfaces=RedundantInterfaces|true
+detectorRepeatedConditionals=RepeatedConditionals|true
+detectorRuntimeExceptionCapture=RuntimeExceptionCapture|true
+detectorSerializableIdiom=SerializableIdiom|true
+detectorStartInConstructor=StartInConstructor|true
+detectorStaticCalendarDetector=StaticCalendarDetector|true
+detectorStringConcatenation=StringConcatenation|true
+detectorSuperfluousInstanceOf=SuperfluousInstanceOf|true
+detectorSuspiciousThreadInterrupted=SuspiciousThreadInterrupted|true
+detectorSwitchFallthrough=SwitchFallthrough|true
+detectorSynchronizeAndNullCheckField=SynchronizeAndNullCheckField|true
+detectorSynchronizeOnClassLiteralNotGetClass=SynchronizeOnClassLiteralNotGetClass|true
+detectorSynchronizingOnContentsOfFieldToProtectField=SynchronizingOnContentsOfFieldToProtectField|true
+detectorURLProblems=URLProblems|true
+detectorUncallableMethodOfAnonymousClass=UncallableMethodOfAnonymousClass|true
+detectorUnnecessaryMath=UnnecessaryMath|true
+detectorUnreadFields=UnreadFields|true
+detectorUseObjectEquals=UseObjectEquals|false
+detectorUselessSubclassMethod=UselessSubclassMethod|false
+detectorVarArgsProblems=VarArgsProblems|true
+detectorVolatileUsage=VolatileUsage|true
+detectorWaitInLoop=WaitInLoop|true
+detectorWrongMapIterator=WrongMapIterator|true
+detectorXMLFactoryBypass=XMLFactoryBypass|true
+detector_threshold=2
+effort=default
+filter_settings=Medium|BAD_PRACTICE,CORRECTNESS,MT_CORRECTNESS,PERFORMANCE,STYLE|false
+filter_settings_neg=MALICIOUS_CODE,NOISE,I18N,SECURITY,EXPERIMENTAL|
+run_at_full_build=false
diff --git a/CharacterManaJ.app/Contents/Resources/Java/CharacterManaJ.jar b/CharacterManaJ.app/Contents/Resources/Java/CharacterManaJ.jar
index 0b6bf22..ba29a7a 100644
Binary files a/CharacterManaJ.app/Contents/Resources/Java/CharacterManaJ.jar and b/CharacterManaJ.app/Contents/Resources/Java/CharacterManaJ.jar differ
diff --git a/CharacterManaJ.jar b/CharacterManaJ.jar
index bdf9143..ba29a7a 100644
Binary files a/CharacterManaJ.jar and b/CharacterManaJ.jar differ
diff --git a/charactermanaj.exe b/charactermanaj.exe
index 52b889c..d58a9ff 100644
Binary files a/charactermanaj.exe and b/charactermanaj.exe differ
diff --git a/resources/appinfo/about.html b/resources/appinfo/about.html
index 87b206e..5dc43d7 100644
--- a/resources/appinfo/about.html
+++ b/resources/appinfo/about.html
@@ -69,7 +69,7 @@ h2 {
æ¬ã½ããã¦ã§ã¢ã®ä½¿ç¨ã«èµ·å ããä¸åã®ç´æ¥æ害ãéæ¥æ害ãå¶çºçæ害ãç¹å¥æ害ãæ²æçæ害ãæ´¾ççæ害ã«ã¤ãã¦ä½è
(seraphy)ããã³åé
å¸è
ãå
±åéçºè
ã¯ä¸åã®è²¬ä»»ãè² ããªããã®ã¨ãã¾ãã
ãã®ã¢ããªã±ã¼ã·ã§ã³ã®ããã¸ã§ã¯ãã¯ãSourceForgeã«ã¦ãªã¼ãã³ã½ã¼ã¹ã¨ãã¦ç®¡çãã¦ããã¾ãã
http://sourceforge.jp/projects/charactermanaj/ããææ°ãã¼ã¸ã§ã³ããã³ã½ã¼ã¹ã³ã¼ããåå¾ãããã¨ãã§ãã¾ãã
-The Apache License Version 2.0ã«å¾ããã ãã§ãèªç±ã«å©ç¨ã§ããä¸ã¤ãæ¹å¤ãããã¨ãã§ãã¾ãã
+The Apache License Version 2.0ã«å¾ããã ãã§ãèªç±ã«å©ç¨ã§ããä¸ã¤ãæ¹å¤ãããã¨ãã§ãã¾ãã
ãã®ã¢ããªã±ã¼ã·ã§ã³èªèº«(javaã³ã¼ã)ã¯seraphyã«ãã£ã¦æ¸ããã¾ããã
人çãªã½ã¼ã¹ã«éãããããããã¡ã³ããã³ã¹ãæ¹åã«æéãããããã¨ãäºæ³ããã¾ãã
ãã®ã¢ããªã±ã¼ã·ã§ã³ãããè¯ããããã¨ããæå¿ããããã¾ãããããã²ããååã»ãé£çµ¡ãã ããã¾ããããé¡ããããã¾ããæè¿ãããã¾ãã
diff --git a/resources/appinfo/about_ja.html b/resources/appinfo/about_ja.html
index 9c3c9ec..24c7dc6 100644
--- a/resources/appinfo/about_ja.html
+++ b/resources/appinfo/about_ja.html
@@ -32,7 +32,7 @@ h2 {
æ¬ã½ããã¦ã§ã¢ã®ä½¿ç¨ã«èµ·å ããä¸åã®ç´æ¥æ害ãéæ¥æ害ãå¶çºçæ害ãç¹å¥æ害ãæ²æçæ害ãæ´¾ççæ害ã«ã¤ãã¦ä½è
(seraphy)ããã³åé
å¸è
ãå
±åéçºè
ã¯ä¸åã®è²¬ä»»ãè² ããªããã®ã¨ãã¾ãã
ãã®ã¢ããªã±ã¼ã·ã§ã³ã®ããã¸ã§ã¯ãã¯ãSourceForgeã«ã¦ãªã¼ãã³ã½ã¼ã¹ã¨ãã¦ç®¡çãã¦ããã¾ãã
http://sourceforge.jp/projects/charactermanaj/ããææ°ãã¼ã¸ã§ã³ããã³ã½ã¼ã¹ã³ã¼ããåå¾ãããã¨ãã§ãã¾ãã
-The Apache License Version 2.0ã«å¾ããã ãã§ãèªç±ã«å©ç¨ã§ããä¸ã¤ãæ¹å¤ãããã¨ãã§ãã¾ãã
+The Apache License Version 2.0ã«å¾ããã ãã§ãèªç±ã«å©ç¨ã§ããä¸ã¤ãæ¹å¤ãããã¨ãã§ãã¾ãã
ãã®ã¢ããªã±ã¼ã·ã§ã³èªèº«(javaã³ã¼ã)ã¯seraphyã«ãã£ã¦æ¸ããã¾ããã
人çãªã½ã¼ã¹ã«éãããããããã¡ã³ããã³ã¹ãæ¹åã«æéãããããã¨ãäºæ³ããã¾ãã
ãã®ã¢ããªã±ã¼ã·ã§ã³ãããè¯ããããã¨ããæå¿ããããã¾ãããããã²ããååã»ãé£çµ¡ãã ããã¾ããããé¡ããããã¾ããæè¿ãããã¾ãã
diff --git a/resources/strings/appconfigdialog.xml b/resources/strings/appconfigdialog.xml
index 405b1d7..38c176a 100644
--- a/resources/strings/appconfigdialog.xml
+++ b/resources/strings/appconfigdialog.xml
@@ -17,8 +17,9 @@
Settings
01;Compression Quality
-02;Zip File Encoding
+02;ZIP File Encoding
03;Common Character Data Directory
+04;The judgment pattern of a color group.('@' is color group name)
10;Preview Max-Width
11;Preview Max-Height
diff --git a/resources/strings/appconfigdialog_ja.xml b/resources/strings/appconfigdialog_ja.xml
index 1a72e45..5e03dca 100644
--- a/resources/strings/appconfigdialog_ja.xml
+++ b/resources/strings/appconfigdialog_ja.xml
@@ -19,6 +19,7 @@
01;JPEGå§ç¸®æã®ã¯ãªãªãã£(1ãæ大ã0.1ãæå°)
02;ZIPãã¡ã¤ã«ã«æ ¼ç´ããã¦ãããã¡ã¤ã«åã®ã¨ã³ã³ã¼ãã£ã³ã°(csWindows31Jãæ¨æº)
03;å
¨ã¦ã¼ã¶ã¼ç¨ãã£ã©ã¯ã¿ã¼å®ç¾©ãã£ã¬ã¯ããª(空ã¯ããã©ã«ã使ç¨)
+04;ãã¼ãåããã«ã©ã¼ã°ã«ã¼ããå¤å®ãããã¿ã¼ã³(æ£è¦è¡¨ç¾)(@ãã«ã©ã¼ã°ã«ã¼ãåã®å ´æã«ãªãã¾ã.)
10;ãã¬ãã¥ã¼ã®åæ表示ã®æ大å¹
11;ãã¬ãã¥ã¼ã®åæ表示ã®æ大é«ã
diff --git a/src/charactermanaj/Main.java b/src/charactermanaj/Main.java
index f2642e4..65b52da 100644
--- a/src/charactermanaj/Main.java
+++ b/src/charactermanaj/Main.java
@@ -96,10 +96,9 @@ public final class Main {
Method mtd = clz.getMethod("setupScreenMenu", MainFrame.class);
mtd.invoke(null, mainFrame);
}
-
- // ã¡ã¤ã³ã¦ã£ã³ãã¦ã表示.
- // (Mainã¡ã½ããã¯ããã®ãã¨çµäºããããSwingã¯ã¢ã¯ãã£ããªã¦ã£ã³ãã¦ããããããã¢ããªã±ã¼ã·ã§ã³ãçµäºããªã.)
- mainFrame.setVisible(true);
+
+ // 表示(ããã³ä½ç½®ããã)
+ mainFrame.showMainFrame();
} catch (Throwable ex) {
// ãªãããã®è´å½çãªåæåã¨ã©ã¼ããã£ãå ´åããã°ã¨ã³ã³ã½ã¼ã«ã«è¡¨ç¤º
@@ -109,7 +108,9 @@ public final class Main {
logger.log(Level.SEVERE, "Application initiation failed.", ex);
}
ErrorMessageHelper.showErrorDialog(null, ex);
- System.exit(1);
+
+ // ã¡ã¤ã³ãã¬ã¼ã ãç ´æ£ãã¾ã.
+ MainFrame.closeAllProfiles();
}
}
diff --git a/src/charactermanaj/model/AppConfig.java b/src/charactermanaj/model/AppConfig.java
index 8afe40b..f7e975e 100644
--- a/src/charactermanaj/model/AppConfig.java
+++ b/src/charactermanaj/model/AppConfig.java
@@ -15,6 +15,7 @@ import java.util.Properties;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
+import java.util.regex.Pattern;
import charactermanaj.util.ApplicationLogHandler;
import charactermanaj.util.BeanPropertiesUtilities;
@@ -165,7 +166,10 @@ public final class AppConfig {
// ç¡è¦ãã
}
}
- } catch (Exception ex) {
+
+ } catch (IOException ex) {
+ throw new RuntimeException("appConfig.xml loading failed.", ex);
+ } catch (RuntimeException ex) {
throw new RuntimeException("appConfig.xml loading failed.", ex);
}
BeanPropertiesUtilities.loadFromProperties(this, config);
@@ -696,4 +700,16 @@ public final class AppConfig {
private long purgeLogDays = 10;
+ public String getPartsColorGroupPattern() {
+ return partsColorGroupPattern;
+ }
+
+ public void setPartsColorGroupPattern(String pattern) {
+ if (pattern != null && pattern.trim().length() > 0) {
+ Pattern.compile(pattern);
+ }
+ partsColorGroupPattern = pattern;
+ }
+
+ private String partsColorGroupPattern = "^.*\\(@\\).*$";
}
diff --git a/src/charactermanaj/model/CharacterData.java b/src/charactermanaj/model/CharacterData.java
index e6c47fb..46ddd1a 100644
--- a/src/charactermanaj/model/CharacterData.java
+++ b/src/charactermanaj/model/CharacterData.java
@@ -209,34 +209,23 @@ public class CharacterData implements Serializable, PartsSpecResolver {
}
/**
- * ãã£ã©ã¯ã¿ã¼ãã¼ã¿ãåãæ§é ã§ããã?
- * ãµã¤ãºãã«ã©ã¼ã°ã«ã¼ããã«ãã´ãªãã¬ã¤ã¤ã¼ã®åæ
å ±ãçãããã°trueããã以å¤ã¯false.
+ * ãã£ã©ã¯ã¿ã¼ãã¼ã¿ãåãæ§é ã§ããã?
+ * ã«ã©ã¼ã°ã«ã¼ããã«ãã´ãªãã¬ã¤ã¤ã¼ã®åæ
å ±ãçãããã°trueããã以å¤ã¯false.
* ä¸è¨ä»¥å¤ã®é
ç®(ã³ã¡ã³ããä½è
ãããªã»ããç)ã«ã¤ãã¦ã¯å¤å®ããªã.
- * ã«ã©ã¼ã°ã«ã¼ãã®è¡¨ç¤ºåãé åºãã«ãã´ãªã®é åºã表示åãè¤æ°ã¢ã¤ãã å¯ãªã©ã®éãã¯æ§é ã®å¤æ´ã¨ã¿ãªããªã.
+ * ãµã¤ãºãã«ã©ã¼ã°ã«ã¼ãã®è¡¨ç¤ºåãé åºãã«ãã´ãªã®é åºã表示åã
+ * è¤æ°ã¢ã¤ãã å¯ãªã©ã®éãã¯æ§é ã®å¤æ´ã¨ã¿ãªããªã.
* ã¬ã¤ã¤ã¼ã¯ã¬ã¤ã¤ã¼IDãéãåããé ã対象ãã£ã¬ã¯ããªã®3ç¹ãå¤æ´ããã¦ããå ´åã¯æ§é ã®å¤æ´ã¨ã¿ãªã.
* ããããåæ°ãã®ãã®ãå¤ãã£ã¦ããå ´åã¯å¤æ´ã¨ã¿ãªã.
* èªåã¾ãã¯ç¸æãValidã§ãªããã°å¸¸ã«falseãè¿ã.
- * @param other æ¯è¼å¯¾è±¡
+ * @param other æ¯è¼å¯¾è±¡, nullå¯
* @return åãæ§é ã§ããã°trueãããã§ãªããã°false
*/
public boolean isSameStructure(CharacterData other) {
- if (other == null) {
- throw new IllegalArgumentException();
- }
- if (!this.isValid() || !other.isValid()) {
+ if (!this.isValid() || other == null || !other.isValid()) {
// èªåã¾ãã¯ç¸æãinvalidã§ããã°æ§é çã«ã¯å¸¸ã«ä¸ä¸è´ã¨è¦ãªã.
return false;
}
- // ãµã¤ãºãçããã?
- if (imageSize == null) {
- if (other.images != null) {
- return false;
- }
- } else if (other.images == null || !imageSize.equals(other.imageSize)) {
- return false;
- }
-
// ã«ã©ã¼ã°ã«ã¼ããçããã? (é åºã¯åããªã)
// IDã®ã¿ã«ãã£ã¦å¤å®ãã
ArrayList colorGroup1 = new ArrayList(getColorGroups());
@@ -261,12 +250,24 @@ public class CharacterData implements Serializable, PartsSpecResolver {
return ret;
}
};
- // ã«ãã´ãªIDé ã«ä¸¦ã³æ¿ãã¦æ¯è¼ãã.
+ // ã«ãã´ãªIDé ã«ä¸¦ã³æ¿ãã¦, IDã®ã¿ãæ¯è¼ãã.
Collections.sort(categories1, sortCategoryId);
Collections.sort(categories2, sortCategoryId);
- if (!categories1.equals(categories2)) {
+ int numOfCategories = categories1.size();
+ if (numOfCategories != categories2.size()) {
+ // ã«ãã´ãªæ°ä¸ä¸è´
return false;
}
+ for (int idx = 0; idx < numOfCategories; idx++) {
+ PartsCategory category1 = categories1.get(idx);
+ PartsCategory category2 = categories2.get(idx);
+ String categoryId1 = category1.getCategoryId();
+ String categoryId2 = category2.getCategoryId();
+ if ( !categoryId1.equals(categoryId2)) {
+ // ã«ãã´ãªIDä¸ä¸è´
+ return false;
+ }
+ }
// ã¬ã¤ã¤ã¼ãçããã?
// IDãéãé åºãdirã«ãã£ã¦ã®ã¿å¤å®ãã.
@@ -291,7 +292,9 @@ public class CharacterData implements Serializable, PartsSpecResolver {
Collections.sort(layers1, sortLayerId);
Collections.sort(layers2, sortLayerId);
- if (!layers1.equals(layers2)) {
+ // IDãé åºãDirã§å¤æãã.(ãã以å¤ã®ã¬ã¤ã¤ã¼æ
å ±ã¯equalsã§ã¯æ¯è¼ãããªã)
+ if ( !layers1.equals(layers2)) {
+ // ã¬ã¤ã¤ã¼ä¸ä¸è´
return false;
}
}
@@ -304,11 +307,80 @@ public class CharacterData implements Serializable, PartsSpecResolver {
* æ§é ãåä¸ã§ãããããµã¤ãºéãããããã¯ã¬ã¤ã¤ã¼ã®é åºãã«ãã´ãªã®é åºã
* ãããã¯ã¬ã¤ã¤ã¼ã¾ãã¯ã«ãã´ãªãå¢ãã¦ããå ´åã§ãæ¸ã£ã¦ããªãå ´åã¯trueã¨ãªã.
* å¼æ°ãnullã®å ´åã¯å¸¸ã«falseã¨ãªã.
- * @param previous åã®ç¶æ
ã®ãã£ã©ã¯ã¿ã¼å®ç¾©ãnullå¯
+ * @param other åã®ç¶æ
ã®ãã£ã©ã¯ã¿ã¼å®ç¾©ãnullå¯
* @return ã¢ããã¼ã³ã³ãããã«ã§ããã°trueãããã§ãªããã°false
*/
- public boolean isUpperCompatibleStructure(CharacterData previous) {
- return isSameStructure(previous); // TODO: å®è£
ããããã¾ã¯ä»®
+ public boolean isUpperCompatibleStructure(CharacterData other) {
+ if (!this.isValid() || other == null || !other.isValid()) {
+ // èªåã¾ãã¯ç¸æãinvalidã§ããã°æ§é çã«ã¯å¸¸ã«äºææ§ãªãã¨è¦ãªã.
+ return false;
+ }
+
+ // ã«ã©ã¼ã°ã«ã¼ããçããã? (é åºã¯åããªã)
+ // IDã®ã¿ã«ãã£ã¦å¤å®ãã
+ ArrayList colorGroupNew = new ArrayList(getColorGroups());
+ ArrayList colorGroupOld = new ArrayList(other.getColorGroups());
+ if (!colorGroupNew.containsAll(colorGroupOld)) {
+ // èªåãç¸æåã®ãã¹ã¦ã®ãã®ãæã£ã¦ããªããã°äºææ§ãªã.
+ return false;
+ }
+
+ // ã«ãã´ãªããã¹ã¦å«ãã? (é åºã¯åããªã)
+ // IDã«ãã£ã¦ã®ã¿å¤å®ãã.
+ Map categoriesNew = new HashMap();
+ for (PartsCategory category : getPartsCategories()) {
+ categoriesNew.put(category.getCategoryId(), category);
+ }
+ Map categoriesOld = new HashMap();
+ for (PartsCategory category : other.getPartsCategories()) {
+ categoriesOld.put(category.getCategoryId(), category);
+ }
+ if ( !categoriesNew.keySet().containsAll(categoriesOld.keySet())) {
+ // èªåãç¸æã®ãã¹ã¦ã®ã«ãã´ãªãæã£ã¦ããªããã°äºææ§ãªã.
+ return false;
+ }
+
+ // ã¬ã¤ã¤ã¼ããã¹ã¦å«ãã?
+ // IDãDirã«ãã£ã¦ã®ã¿å¤å®ãã.
+ for (Map.Entry categoryOldEntry : categoriesOld.entrySet()) {
+ String categoryId = categoryOldEntry.getKey();
+ PartsCategory categoryOld = categoryOldEntry.getValue();
+ PartsCategory categoryNew = categoriesNew.get(categoryId);
+ if (categoryNew == null) {
+ return false;
+ }
+
+ Map layersNew = new HashMap();
+ for (Layer layer : categoryNew.getLayers()) {
+ layersNew.put(layer.getId(), layer);
+ }
+ Map layersOld = new HashMap();
+ for (Layer layer : categoryOld.getLayers()) {
+ layersOld.put(layer.getId(), layer);
+ }
+
+ if ( !layersNew.keySet().containsAll(layersOld.keySet())) {
+ // èªåãç¸æã®ãã¹ã¦ã®ã¬ã¤ã¤ã¼(ID)ãæã£ã¦ããªããã°äºææ§ãªã.
+ return false;
+ }
+ for (Map.Entry layerOldEntry : layersOld.entrySet()) {
+ String layerId = layerOldEntry.getKey();
+ Layer layerOld = layerOldEntry.getValue();
+ Layer layerNew = layersNew.get(layerId);
+ if (layerNew == null) {
+ return false;
+ }
+ String dirOld = layerOld.getDir();
+ String dirNew = layerNew.getDir();
+ if ( !dirOld.equals(dirNew)) {
+ // ãã£ã¬ã¯ããªãä¸è´ããªããã°äºææ§ãªã.
+ // (XXX: 大æåã»å°æåãå³æ ¼ã«åºå¥ãã¦ãã. Windowsç°å¢ã¯ã©ãããã¹ãã?)
+ return false;
+ }
+ }
+ }
+
+ return true;
}
/**
diff --git a/src/charactermanaj/model/PartsColorInfo.java b/src/charactermanaj/model/PartsColorInfo.java
index 3886631..527e993 100644
--- a/src/charactermanaj/model/PartsColorInfo.java
+++ b/src/charactermanaj/model/PartsColorInfo.java
@@ -6,6 +6,8 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import charactermanaj.graphics.filters.ColorConvertParameter;
@@ -17,6 +19,11 @@ import charactermanaj.graphics.filters.ColorConvertParameter;
*/
public final class PartsColorInfo extends AbstractMap implements Serializable, Cloneable {
+ /**
+ * ãã¬ã¼
+ */
+ private static final Logger logger = Logger.getLogger(PartsColorInfo.class.getName());
+
private static final long serialVersionUID = -8639109147043912257L;
/**
@@ -42,22 +49,45 @@ public final class PartsColorInfo extends AbstractMap implemen
init();
}
- protected PartsColorInfo(PartsColorInfo src) {
- if (src == null) {
+ @Override
+ public PartsColorInfo clone() {
+ try {
+ PartsColorInfo inst = (PartsColorInfo) super.clone();
+ inst.colorInfoMap = new HashMap();
+ for (Map.Entry entry : colorInfoMap.entrySet()) {
+ Layer layer = entry.getKey();
+ ColorInfo colorInfo = entry.getValue();
+ inst.colorInfoMap.put(layer, colorInfo.clone());
+ }
+ return inst;
+
+ } catch (CloneNotSupportedException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ /**
+ * ãã¼ãã«ã©ã¼æ
å ±ãæå®ãããã¼ãã«ãã´ãªã«åå¨ããã¬ã¤ã¤ã¼ã«æ£è¦åãã¦è¿ã.
+ * ã«ãã´ãªã«åå¨ããªãã¬ã¤ã¤ã¼ã®æ
å ±ã¯ç ´æ£ãããçµæã¯æå¹ãªã¬ã¤ã¤ã¼ã®ã¿ã®è²æ
å ±ã¨ãªã.
+ * @param partsCategory ãã¼ãã«ãã´ãª
+ * @return æ£è¦åããããã¼ãã«ã©ã¼æ
å ±
+ */
+ public PartsColorInfo createCompatible(PartsCategory partsCategory) {
+ if (partsCategory == null) {
throw new IllegalArgumentException();
}
- this.partsCategory = src.partsCategory;
- init();
- for (Map.Entry entry : src.colorInfoMap.entrySet()) {
+ PartsColorInfo newInfo = new PartsColorInfo(partsCategory);
+ newInfo.init();
+ for (Map.Entry entry : colorInfoMap.entrySet()) {
Layer layer = entry.getKey();
ColorInfo colorInfo = entry.getValue();
- colorInfoMap.put(layer, colorInfo.clone());
+ if (partsCategory.hasLayer(layer)) {
+ newInfo.put(layer, colorInfo.clone());
+ } else {
+ logger.log(Level.INFO, "missing layer '" + layer + "' in " + partsCategory);
+ }
}
- }
-
- @Override
- public PartsColorInfo clone() {
- return new PartsColorInfo(this);
+ return newInfo;
}
/**
diff --git a/src/charactermanaj/model/PartsColorManager.java b/src/charactermanaj/model/PartsColorManager.java
index fc95491..a8d5fca 100644
--- a/src/charactermanaj/model/PartsColorManager.java
+++ b/src/charactermanaj/model/PartsColorManager.java
@@ -20,24 +20,58 @@ public class PartsColorManager {
private static final Logger logger = Logger.getLogger(PartsColorManager.class.getName());
/**
+ * ã«ãã´ãªãã¨ã®ãã¼ãã«ã©ã¼æ
å ±.
+ * @author seraphy
+ */
+ public static final class CategoryColorInfo {
+
+ private final PartsColorInfo partsColorInfo;
+
+ private final boolean applyAll;
+
+ public CategoryColorInfo(PartsColorInfo partsColorInfo, boolean applyAll) {
+ this.partsColorInfo = partsColorInfo;
+ this.applyAll = applyAll;
+ }
+
+ public PartsColorInfo getPartsColorInfo() {
+ return partsColorInfo;
+ }
+
+ public boolean isApplyAll() {
+ return applyAll;
+ }
+ }
+
+ /**
* ãã¼ãåä½ã§ã®ã«ã©ã¼ã°ã«ã¼ããå«ãè²æ
å ±.
* ã«ãã´ãªå
¨ä½ã«é©ç¨ãããå ´åã¯ãã¼ãåä½ã®è²æ
å ±ã¯ãªã»ãããã.
*/
- private HashMap partsColorInfoMap = new HashMap();
+ private HashMap partsColorInfoMap
+ = new HashMap();
/**
* ã«ãã´ãªãã¨ã«å
±éã¨ãªãå ´åã®ã«ã©ã¼ã°ã«ã¼ããå«ãè²æ
å ±.
* ãã¼ãåä½ã®è²æ
å ±ãå®ç¾©ããã¦ããªãå ´åãã«ãã´ãªåä½ã§ã®æ
å ±ã使ç¨ããã.
*/
- private HashMap categoryColorInfoMap = new HashMap();
+ private HashMap categoryColorInfoMap
+ = new HashMap();
/**
* ã«ã©ã¼ã°ã«ã¼ããã¨ã®è²æ
å ±.
*/
- private HashMap recentColorGroupMap = new HashMap();
+ private HashMap recentColorGroupMap
+ = new HashMap();
+ /**
+ * ãã¼ãè¨å®ã®ãªã¾ã«ã
+ */
private PartsSpecResolver partsSpecResolver;
+ /**
+ * ãã¼ãè¨å®ãªã¾ã«ããæå®ãã¦æ§ç¯ãã.
+ * @param partsSpecResolver ãªã¾ã«ã
+ */
public PartsColorManager(PartsSpecResolver partsSpecResolver) {
if (partsSpecResolver == null) {
throw new IllegalArgumentException();
@@ -87,15 +121,16 @@ public class PartsColorManager {
PartsCategory partsCategory = partsIdentifier.getPartsCategory();
if (applyAll) {
- // ã«ãã´ãªæå®
- resetPartsColorInfo(partsCategory); // ãã¼ãåå¥è²ããªã»ãããããã¨ã§ã«ãã´ãªãåªå
ããã.
-
+ // ã«ãã´ãªæå®ã®å ´å
+ // ãã¼ãåå¥è²ããªã»ãããããã¨ã§ã«ãã´ãªãåªå
ããã.
+ resetPartsColorInfo(partsCategory);
+
if (logger.isLoggable(Level.FINEST)) {
logger.log(Level.FINEST, "setPartsColorInfo(Category): " + partsIdentifier + "=" + partsColorInfo);
}
} else {
- // ãã¼ãåå¥æå®
+ // ãã¼ãåå¥æå®ã®å ´å
partsColorInfoMap.put(partsIdentifier, partsColorInfo);
if (logger.isLoggable(Level.FINEST)) {
@@ -103,12 +138,27 @@ public class PartsColorManager {
}
}
- setRecentColorGroup(partsColorInfo);
- categoryColorInfoMap.put(partsCategory, partsColorInfo);
+ // ã«ã©ã¼ã°ã«ã¼ãã¨ãã¦ã®ææ°ã®ã«ã©ã¼æ
å ±ãä¿åãã.(æå¹ãªã«ã©ã¼ã°ã«ã¼ãã§é£åæå®ãããå ´åã®ã¿)
+ // ãã ããããã¹ã¦ã«é©ç¨ãã§ãªãå ´åã¯ä¿åããªã.
+ if (applyAll) {
+ setRecentColorGroup(partsColorInfo);
+ }
+
+ // ã«ãã´ãªãã¨ã®ææ°ã®è²æ
å ±ãè¨å®ãã.
+ // (ããã¹ã¦ã«é©ç¨ãã§ããããåæ°é¸æã«ãã´ãªã§ãã¾ã ããã¹ã¦ã«é©ç¨ãã®è²æ
å ±ããªãå ´åã®ã¿.)
+ // (è¤æ°é¸æã«ãã´ãªã®å ´åã¯æ示çã«ããã¹ã¦ã«é©ç¨ããé¸æãã¦ããªããããä¿åãããªã.)
+ CategoryColorInfo categoryColorInfo = categoryColorInfoMap.get(partsCategory);
+ if (applyAll ||
+ (!partsCategory.isMultipleSelectable() &&
+ (categoryColorInfo == null || !categoryColorInfo.isApplyAll()))) {
+ categoryColorInfo = new CategoryColorInfo(partsColorInfo, applyAll);
+ categoryColorInfoMap.put(partsCategory, categoryColorInfo);
+ }
}
/**
* ãã¼ãã®è²æ
å ±ãæå®ãã¦ããã¼ãèå¥åã®åã¬ã¤ã¼ã¤ã®è²ã°ã«ã¼ãæ
å ±ãä¿åãã¾ã.
+ * é£åæå®ãæå¹ã§ãããæå¹ãªã«ã©ã¼ã°ã«ã¼ãã§ããå ´åã®ã¿ä¿åããã¾ã.
* @param partsColorInfo ãã¼ãèå¥å
*/
protected void setRecentColorGroup(PartsColorInfo partsColorInfo) {
@@ -158,7 +208,7 @@ public class PartsColorManager {
* @param partsCategory ãã¼ãã«ãã´ãª
* @return æå®ãããã¼ãã«ãã´ãªã®è²æ
å ±ãã¾ãã¯null
*/
- public PartsColorInfo getPartsColorInfo(PartsCategory partsCategory) {
+ public CategoryColorInfo getPartsColorInfo(PartsCategory partsCategory) {
return categoryColorInfoMap.get(partsCategory);
}
@@ -170,16 +220,19 @@ public class PartsColorManager {
}
/**
- * æå®ããã«ãã´ãªã«å±ãããã¼ãèå¥åãã¨ã®è²æ
å ±ããªã»ãããã¾ã.
- * å¼æ°partsCategoryãnullã®å ´åã¯å
¨ãã¼ãèå¥åããªã»ãããã¾ã.
+ * æå®ããã«ãã´ãªã¨ãã«ãã´ãªã«å±ãããã¼ãèå¥åãã¨ã®è²æ
å ±ããªã»ãããã¾ã.
+ * å¼æ°partsCategoryãnullã®å ´åã¯å
¨ãã¼ãèå¥åãå
¨ã«ãã´ãªã¨ããã¹ã¦ã®ã«ã©ã¼ã°ã«ã¼ãããªã»ãããã¾ã.
* @param partsCategory ãã¼ãã«ãã´ãªã¾ãã¯null
*/
public void resetPartsColorInfo(PartsCategory partsCategory) {
if (partsCategory == null) {
+ recentColorGroupMap.clear();
partsColorInfoMap.clear();
+ categoryColorInfoMap.clear();
return;
}
+ categoryColorInfoMap.remove(partsCategory);
Iterator> ite = partsColorInfoMap.entrySet().iterator();
while (ite.hasNext()) {
Map.Entry entry = ite.next();
@@ -199,34 +252,48 @@ public class PartsColorManager {
PartsCategory category = partsIdentifier.getPartsCategory();
PartsColorInfo partsColorInfo = new PartsColorInfo(category);
- // åä¸ã«ãã´ãªã®æè¿è¨å®ãããã«ã©ã¼æ
å ±ãé©ç¨ãã.
- PartsColorInfo categoryPartsColorInfo = categoryColorInfoMap.get(category);
- if (categoryPartsColorInfo != null) {
- for (Map.Entry entry : categoryPartsColorInfo.entrySet()) {
- Layer layer = entry.getKey();
- ColorInfo colorInfo = entry.getValue();
- if (colorInfo != null && partsColorInfo.containsKey(layer)) {
- partsColorInfo.put(layer, colorInfo.clone());
- }
- }
- }
-
- // ãã¼ãåºæã®è¨å®ãããããã¼ãåºå®ã®ã«ã©ã¼ã°ã«ã¼ãã®æå®ãããã°
- // å
¨ã¬ã¤ã¤ã¼ã該å½ã«ã©ã¼ã°ã«ã¼ãã«è¨å®ãã.
+ // ãã¼ãåºæã®ã«ã©ã¼ã°ã«ã¼ãã®æå®ãããã?
PartsSpec partsSpec = partsSpecResolver.getPartsSpec(partsIdentifier);
+ ColorGroup partsSpecColorGroup = null;
if (partsSpec != null) {
- ColorGroup colorGroup = partsSpec.getColorGroup();
- if (colorGroup != null && colorGroup.isEnabled()) {
- for (Map.Entry entry : partsColorInfo.entrySet()) {
+ partsSpecColorGroup = partsSpec.getColorGroup();
+ }
+
+ if (partsSpecColorGroup != null && partsSpecColorGroup.isEnabled()) {
+ // ãã¼ãåºå®ã®ã«ã©ã¼ã°ã«ã¼ãã®æå®ãããã°
+ // å
¨ã¬ã¤ã¤ã¼ã該å½ã«ã©ã¼ã°ã«ã¼ãã«è¨å®ãã.
+ for (Map.Entry entry : partsColorInfo.entrySet()) {
+ ColorInfo colorInfo = entry.getValue();
+ colorInfo = colorInfo.clone();
+ colorInfo.setColorGroup(partsSpecColorGroup);
+ colorInfo.setSyncColorGroup(true);
+ entry.setValue(colorInfo);
+ }
+
+ } else {
+ // ãã¼ãåºæã®ã«ã©ã¼ã°ã«ã¼ãããªããã°
+ // åä¸ã«ãã´ãªã®æè¿è¨å®ãããã«ã©ã¼æ
å ±ããã¨ã«ããã¼ãã«ã©ã¼æ
å ±ãä½æãã.
+ CategoryColorInfo categoryColorInfo = categoryColorInfoMap.get(category);
+ if (categoryColorInfo != null) {
+ PartsColorInfo categoryPartsColorInfo = categoryColorInfo.getPartsColorInfo();
+ for (Map.Entry entry : categoryPartsColorInfo.entrySet()) {
+ Layer layer = entry.getKey();
ColorInfo colorInfo = entry.getValue();
- if (colorInfo != null) {
+ if (colorInfo != null && partsColorInfo.containsKey(layer)) {
colorInfo = colorInfo.clone();
- } else {
- colorInfo = new ColorInfo();
+
+ // ãã ããåä¸ã«ãã´ãªã«è¨å®ãããã«ã©ã¼æ
å ±ãããã¹ã¦ã«é©ç¨ãã§ãªãå ´åã¯ã
+ // ã¬ã¤ã¤ã¼åºæã®ã«ã©ã¼ã°ã«ã¼ããç¶æãã.
+ if ( !categoryColorInfo.isApplyAll()) {
+ ColorGroup layerColorGroup = layer.getColorGroup();
+ if (layerColorGroup == null) {
+ layerColorGroup = ColorGroup.NA;
+ }
+ colorInfo.setColorGroup(layerColorGroup);
+ }
+
+ partsColorInfo.put(layer, colorInfo);
}
- colorInfo.setColorGroup(colorGroup);
- colorInfo.setSyncColorGroup(true);
- entry.setValue(colorInfo);
}
}
}
diff --git a/src/charactermanaj/model/PartsSet.java b/src/charactermanaj/model/PartsSet.java
index ebf5123..41bfe92 100644
--- a/src/charactermanaj/model/PartsSet.java
+++ b/src/charactermanaj/model/PartsSet.java
@@ -100,6 +100,7 @@ public final class PartsSet extends AbstractMap partsColorInfoEntry : org.partsColorInfoMap.entrySet()) {
PartsIdentifier partsIdentifier = partsColorInfoEntry.getKey();
if (resolver != null) {
@@ -117,11 +118,13 @@ public final class PartsSet extends AbstractMap> partsEntry : org.parts.entrySet()) {
PartsCategory orgPartsCategory = partsEntry.getKey();
PartsCategory partsCategory = orgPartsCategory;
@@ -153,7 +156,7 @@ public final class PartsSet extends AbstractMap ownList = get(category);
+ // ã«ãã´ãªãä¸è´ããåã«ãã´ãªã«ç»é²ããã¦ãããã¼ãèå¥åã®ãªã¹ããé åºãå«ãã¦ä¸è´ããå ´åã
+ // æ§é çã«ä¸è´ããã¨å¤å®ãã.
+ for (Map.Entry> entry : entrySet()) {
+ PartsCategory category = entry.getKey();
+ List ownList = entry.getValue();
List otherList = other.get(category);
if (ownList == null || otherList == null || !ownList.equals(otherList)) {
return false;
}
}
- // ã«ãã´ãªãä¸è´ããåã«ãã´ãªã«ç»é²ããã¦ãããã¼ãèå¥åã®ãªã¹ããé åºãå«ãã¦ä¸è´ããå ´åã
- // æ§é çã«ä¸è´ããã¨å¤å®ãã.
return true;
}
return false;
diff --git a/src/charactermanaj/model/io/AbstractCharacterDataArchivedFileWriter.java b/src/charactermanaj/model/io/AbstractCharacterDataArchivedFileWriter.java
index 651e315..ccafac8 100644
--- a/src/charactermanaj/model/io/AbstractCharacterDataArchivedFileWriter.java
+++ b/src/charactermanaj/model/io/AbstractCharacterDataArchivedFileWriter.java
@@ -1,13 +1,18 @@
package charactermanaj.model.io;
import java.awt.Color;
+import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
+import java.io.Writer;
import java.nio.charset.Charset;
+import java.sql.Timestamp;
+import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -16,10 +21,12 @@ import charactermanaj.graphics.io.ImageSaveHelper;
import charactermanaj.model.AppConfig;
import charactermanaj.model.CharacterData;
import charactermanaj.model.Layer;
+import charactermanaj.model.PartsCategory;
import charactermanaj.model.PartsFiles;
import charactermanaj.model.PartsIdentifier;
import charactermanaj.model.PartsManageData;
import charactermanaj.model.PartsManageDataConverter;
+import charactermanaj.model.PartsSet;
import charactermanaj.model.PartsSpec;
public abstract class AbstractCharacterDataArchivedFileWriter extends AbstractCharacterDataFileWriter {
@@ -46,10 +53,84 @@ public abstract class AbstractCharacterDataArchivedFileWriter extends AbstractCh
throws IOException {
CharacterDataPersistent persist = CharacterDataPersistent.getInstance();
- // character data
+ // character.xmlã®åºå
putNextEntry("character.xml", 0);
persist.writeXMLCharacterData(characterData, getOutputStream());
closeEntry();
+
+ // character.iniã®åºå
+ internalWriteCharacterIni(characterData);
+ }
+
+ /**
+ * character.iniãåºåãã¾ã.
+ * @param characterData ãã£ã©ã¯ã¿ã¼ãã¼ã¿
+ * @throws IOException åºåã«å¤±æããå ´å
+ */
+ protected void internalWriteCharacterIni(CharacterData characterData) throws IOException {
+ StringBuilder buf = new StringBuilder();
+
+ buf.append("; created by charactermanaj "
+ + new Timestamp(System.currentTimeMillis()) + "\r\n");
+
+ buf.append("[Size]\r\n");
+ Dimension dim = characterData.getImageSize();
+ if (dim == null) {
+ dim = new Dimension(300, 400);
+ }
+ buf.append("size_x=" + dim.width + "\r\n");
+ buf.append("size_y=" + dim.height + "\r\n");
+
+ buf.append("\r\n");
+ buf.append("[Parts]\r\n");
+
+ Map partsMap = new HashMap();
+ for (PartsCategory partsCategory : characterData.getPartsCategories()) {
+ String categoryId = partsCategory.getCategoryId();
+ partsMap.put(categoryId, "");
+ }
+
+ Map partsSets = characterData.getPartsSets();
+ PartsSet partsSet = partsSets.get(characterData.getDefaultPartsSetId());
+ if (partsSet == null && !partsSets.isEmpty()) {
+ // ããã©ã«ãã®ãã¼ãã»ãããæå®ããã¦ããªãå ´åã¯ãã©ãã1ã¤ãé¸æãã.
+ partsSet = partsSets.values().iterator().next();
+ }
+ if (partsSet != null) {
+ for (Map.Entry> entry : partsSet
+ .entrySet()) {
+ PartsCategory partsCategory = entry.getKey();
+ StringBuilder partsNames = new StringBuilder();
+ for (PartsIdentifier partsIdentifier : entry.getValue()) {
+ if (partsNames.length() > 0) {
+ partsNames.append(",");
+ }
+ partsNames.append(partsIdentifier.getPartsName());
+ }
+ String categoryId = partsCategory.getCategoryId();
+ partsMap.put(categoryId, partsNames.toString());
+ }
+ }
+ for (PartsCategory partsCategory : characterData.getPartsCategories()) {
+ String categoryId = partsCategory.getCategoryId();
+ String partsNames = partsMap.get(categoryId);
+ buf.append(categoryId + "=" + partsNames + "\r\n");
+ }
+
+ // è²æ
å ±ã¯ãã¹ã¦ããã¼(character.iniã¯è²æ
å ±ãçç¥ãã¦ãåé¡ãªãããã ããä¸å¿)
+ buf.append("\r\n");
+ buf.append("[Color]\r\n");
+ buf.append("hair_rgb=0\r\n");
+ buf.append("hair_gray=0\r\n");
+ buf.append("eye_rgb=0\r\n");
+ buf.append("eye_gray=0\r\n");
+ buf.append("skin_rgb=0\r\n");
+ buf.append("skin_gray=0\r\n");
+ buf.append("body_rgb=0\r\n");
+ buf.append("body_gray=0\r\n");
+
+ // UTF16LEã§åºåãã.
+ internalWriteTextUTF16LE("character.ini", buf.toString());
}
@Override
@@ -68,12 +149,20 @@ public abstract class AbstractCharacterDataArchivedFileWriter extends AbstractCh
os.write((byte) 0xff);
os.write((byte) 0xfe);
os.flush();
- OutputStreamWriter wr = new OutputStreamWriter(os, Charset.forName("UTF-16LE"));
+ Writer wr = new OutputStreamWriter(os, Charset.forName("UTF-16LE")) {
+ @Override
+ public void close() throws IOException {
+ // Zipã®OutputStreamãã¯ãã¼ãºãã¦ã¯ãªããªããã
+ // OutputStreamWriterèªèº«ã¯ã¯ãã¼ãºã¯å¼ã³åºããªã.
+ flush();
+ closeEntry();
+ }
+ };
try {
wr.append(contents);
wr.flush();
} finally {
- closeEntry();
+ wr.close();
}
}
diff --git a/src/charactermanaj/model/io/ExportInfoKeys.java b/src/charactermanaj/model/io/ExportInfoKeys.java
index 0d0e680..8a0d8c4 100644
--- a/src/charactermanaj/model/io/ExportInfoKeys.java
+++ b/src/charactermanaj/model/io/ExportInfoKeys.java
@@ -8,8 +8,6 @@ public interface ExportInfoKeys {
String EXPORT_CHARACTER_DATA = "EXPORT_CHARACTER_DATA";
- String EXPORT_SUBSET = "EXPORT_SUBSET";
-
String EXPORT_PARTS_IMAGES = "EXPORT_PARTS_IMAGES";
String EXPORT_TIMESTAMP = "EXPORT_TIMESTAMP";
diff --git a/src/charactermanaj/model/io/PartsSpecDecorateLoader.java b/src/charactermanaj/model/io/PartsSpecDecorateLoader.java
index fd0fef3..dc27b4b 100644
--- a/src/charactermanaj/model/io/PartsSpecDecorateLoader.java
+++ b/src/charactermanaj/model/io/PartsSpecDecorateLoader.java
@@ -3,7 +3,10 @@ package charactermanaj.model.io;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import charactermanaj.model.AppConfig;
import charactermanaj.model.ColorGroup;
import charactermanaj.model.PartsCategory;
import charactermanaj.model.PartsIdentifier;
@@ -47,16 +50,24 @@ public class PartsSpecDecorateLoader implements PartsDataLoader {
}
/**
- * ãã¼ãèå¥åã®è¡¨ç¤ºåã®æ«å°¾ãã«ã©ã¼ã°ã«ã¼ãã®è¡¨ç¤ºåãæ¬å¼§ã§ããã£ããã®ã¨çããå ´åã
+ * ãã¼ãèå¥åã®è¡¨ç¤ºåã«ãã«ã©ã¼ã°ã«ã¼ãã®è¡¨ç¤ºåã«ããå¤å®ããããã¿ã¼ã³ã«åè´ããå ´åã
* ãã¼ãè¨å®ã®ã«ã©ã¼ã°ã«ã¼ããããã®ã«ã©ã¼ã°ã«ã¼ãã¨ãã¦è¨å®ãã.
* @param partsSpecs ãã¼ãããã
*/
protected void decolatePartsSpec(Map partsSpecs) {
+ String templ = AppConfig.getInstance().getPartsColorGroupPattern();
+ if (templ == null || templ.trim().length() == 0) {
+ // ãã¿ã¼ã³ãè¨å®ããã¦ããªãå ´åã¯ç¡è¦ãã.
+ return;
+ }
// ãã¼ãåã«ã«ã©ã¼ã°ã«ã¼ããå«ã¾ããå ´åããããç»é²ãã.
for (ColorGroup colorGroup : colorGroups) {
- String suffix = "(" + colorGroup.getLocalizedName() + ")";
+ String pattern = templ.replace("@", colorGroup.getLocalizedName());
+ Pattern pat = Pattern.compile(pattern);
for (PartsSpec partsSpec : partsSpecs.values()) {
- if (partsSpec.getPartsIdentifier().getLocalizedPartsName().endsWith(suffix)) {
+ Matcher mat = pat.matcher(partsSpec.getPartsIdentifier()
+ .getLocalizedPartsName());
+ if (mat.matches()) {
partsSpec.setColorGroup(colorGroup);
}
}
diff --git a/src/charactermanaj/model/util/StartupSupport.java b/src/charactermanaj/model/util/StartupSupport.java
index ecd9319..0a149f0 100644
--- a/src/charactermanaj/model/util/StartupSupport.java
+++ b/src/charactermanaj/model/util/StartupSupport.java
@@ -2,8 +2,10 @@ package charactermanaj.model.util;
import java.io.File;
import java.net.URI;
+import java.net.URL;
import java.util.HashMap;
import java.util.Map;
+import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -36,13 +38,15 @@ public abstract class StartupSupport {
new PurgeUnusedCache(),
};
for (StartupSupport startup : startups) {
- logger.log(Level.FINE, "startup operation start.");
+ logger.log(Level.FINE, "startup operation start. class="
+ + startup.getClass().getSimpleName());
try {
startup.doStartup();
+ logger.log(Level.INFO, "startup operation is done.");
+
} catch (Exception ex) {
logger.log(Level.WARNING, "startup operation failed.", ex);
}
- logger.log(Level.INFO, "startup operation is done.");
}
}
};
@@ -123,12 +127,69 @@ class UpgradeCache extends StartupSupport {
abstract class StartupSupportForDocBasedData extends StartupSupport {
/**
+ * character.xmlã®ãã¡ã¤ã«ä½ç½®ã示ãUUID表ç¾ãç®å®ããããã®ã¢ã«ã´ãªãºã ã®é¸æè¢.
+ * @author seraphy
+ */
+ protected enum DocBaseSignatureStoratage {
+
+ /**
+ * æ°å½¢å¼ã®character.xmlã®UUIDãåå¾ãã.
+ * charatcer.xmlãã¡ã¤ã«ã®URIãæååã«ãããã®ã®ã¿ã¤ã3-UUID表ç¾.
+ */
+ NEW_FORMAT() {
+ @Override
+ public String getDocBaseSignature(File characterXmlFile) {
+ URI docBase = characterXmlFile.toURI();
+ UserDataFactory userDataFactory = UserDataFactory.getInstance();
+ return userDataFactory.getMangledNamedPrefix(docBase);
+ }
+ },
+
+ /**
+ * æ§å½¢å¼ã®character.xmlã®UUIDãåå¾ãã.
+ * charatcer.xmlãã¡ã¤ã«ã®URLãæååã«ãããã®ã®ã¿ã¤ã3-UUID表ç¾.
+ */
+ OLD_FORMAT() {
+ @Override
+ public String getDocBaseSignature(File characterXmlFile) {
+ try {
+ @SuppressWarnings("deprecation")
+ URL url = characterXmlFile.toURL();
+ return UUID.nameUUIDFromBytes(url.toString().getBytes()).toString();
+
+ } catch (Exception ex) {
+ logger.log(Level.WARNING,
+ "character.xmlã®ãã¡ã¤ã«ä½ç½®ãUUIDåã§ãã¾ããã:"
+ + characterXmlFile, ex);
+ return null;
+ }
+ }
+ },
+ ;
+
+ /**
+ * ãã¬ã¼
+ */
+ private static Logger logger = Logger.getLogger(
+ DocBaseSignatureStoratage.class.getName());
+
+ /**
+ * character.xmlããuuid表ç¾ã®ãã¬ãã£ãã¯ã¹ãç®å®ãã.
+ * @param characterXmlFile character.xmlã®ãã¡ã¤ã«
+ * @return UUID
+ */
+ public abstract String getDocBaseSignature(File characterXmlFile);
+ }
+
+ /**
* ãã¹ã¦ã®ã¦ã¼ã¶ããã³ã·ã¹ãã ã®ãã£ã©ã¯ã¿ã¼ãã¼ã¿ã®DocBaseããã¨ã¨ããããã·ã¥å¤(Prefix)ã®æååããã¼ã¨ãã
* ãã£ã©ã¯ã¿ã¼ãã£ã¬ã¯ããªãå¤ã¨ããããããè¿ã.
* @return DocBaseããã¨ã¨ããããã·ã¥å¤ã®æåå表è¨ããã¼ããã£ã©ã¯ã¿ã¼ãã£ã¬ã¯ããªãå¤ã¨ããããã
*/
- protected Map getDocBaseMap() {
- UserDataFactory userDataFactory = UserDataFactory.getInstance();
+ protected Map getDocBaseMap(DocBaseSignatureStoratage storatage) {
+ if (storatage == null) {
+ throw new IllegalArgumentException();
+ }
AppConfig appConfig = AppConfig.getInstance();
File[] charactersDirs = {
@@ -151,9 +212,10 @@ abstract class StartupSupportForDocBasedData extends StartupSupport {
if ( !characterXml.exists()) {
continue;
}
- URI docBase = characterXml.toURI();
- String docBaseSig = userDataFactory.getMangledNamedPrefix(docBase);
- docBaseSignatures.put(docBaseSig, characterDir);
+ String docBaseSig = storatage.getDocBaseSignature(characterXml);
+ if (docBaseSig != null) {
+ docBaseSignatures.put(docBaseSig, characterDir);
+ }
}
}
return docBaseSignatures;
@@ -213,10 +275,11 @@ class UpgradeFavoritesXml extends StartupSupportForDocBasedData {
File appData = userDataFactory.getSpecialDataDir(null);
// ãã£ã©ã¯ã¿ã¼ãã¼ã¿ãã£ã¬ã¯ããªãèµ°æ»ãdocBaseã®èå¥åã®ä¸è¦§ãåå¾ãã
- Map docBaseSignatures = getDocBaseMap();
+ Map docBaseSignatures = getDocBaseMap(
+ DocBaseSignatureStoratage.OLD_FORMAT);
// ver0.94ã¾ã§ã¯*.favorite.xmlã¯ã¦ã¼ã¶ãã£ã¬ã¯ããªç´ä¸ã«é
åãã¦ããã
- // ver0.95以éã¯åãã£ã©ã¯ã¿ã¼ãã£ã¬ã¯ããªã«ç§»åãããããæ§docbase-favorites.xmlãæ®ã£ã¦ããã°ç§»åãã
+ // ver0.95以éã¯åãã£ã©ã¯ã¿ã¼ãã£ã¬ã¯ããªã«ç§»åãããããæ§docbase-id-favorites.xmlãæ®ã£ã¦ããã°ç§»åãã
// ã¦ã¼ã¶ãã£ã¬ã¯ããªç´ä¸ã«ãã*-facotites.xmlãåæãã
Map favorites = getUUIDMangledNamedMap(appData, "-favorites.xml");
@@ -253,7 +316,8 @@ class PurgeUnusedCache extends StartupSupportForDocBasedData {
@Override
public void doStartup() {
// ãã£ã©ã¯ã¿ã¼ãã¼ã¿ãã£ã¬ã¯ããªãèµ°æ»ãdocBaseã®èå¥åã®ä¸è¦§ãåå¾ãã
- Map docBaseSignatures = getDocBaseMap();
+ Map docBaseSignatures = getDocBaseMap(
+ DocBaseSignatureStoratage.NEW_FORMAT);
// ãã£ãã·ã¥ã®ä¿åå
ãåå¾ãã.
UserDataFactory userDataFactory = UserDataFactory.getInstance();
@@ -272,8 +336,9 @@ class PurgeUnusedCache extends StartupSupportForDocBasedData {
File cacheFile = cacheEntry.getValue();
try {
if ( !docBaseSignatures.containsKey(mangledUUID)) {
- cacheFile.delete();
- logger.log(Level.INFO, "purge unused cache: " + cacheFile);
+ boolean result = cacheFile.delete();
+ logger.log(Level.INFO, "purge unused cache: " + cacheFile
+ + "/succeeded=" + result);
}
} catch (Exception ex) {
@@ -310,8 +375,9 @@ class PurgeOldLogs extends StartupSupport {
if (file.isFile() && file.canWrite() && name.endsWith(".log")) {
long lastModified = file.lastModified();
if (lastModified > 0 && lastModified < purgeThresold) {
- file.delete();
- logger.log(Level.INFO, "remove file " + file);
+ boolean result = file.delete();
+ logger.log(Level.INFO, "remove file " + file
+ + "/succeeded=" + result);
}
}
diff --git a/src/charactermanaj/ui/ColorDialog.java b/src/charactermanaj/ui/ColorDialog.java
index 03a1b05..b8aaccf 100644
--- a/src/charactermanaj/ui/ColorDialog.java
+++ b/src/charactermanaj/ui/ColorDialog.java
@@ -203,6 +203,12 @@ public class ColorDialog extends JDialog {
gbc.weighty = 0.;
chkApplyAll = new JCheckBox(strings.getProperty("checkbox.applyAllItems"));
chkApplyAll.setSelected(!partsCategory.isMultipleSelectable());
+ chkApplyAll.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ // ãã¹ã¦ã«é©ç¨ã®ãã§ãã¯ãå¤æ´ãããå ´åã¯å
¨ã¬ã¤ã¤ã¼ã®è²ã®å¤æ´éç¥ãåºã.
+ apply();
+ }
+ });
btnPanel.add(chkApplyAll, gbc);
gbc.gridx = colIdx++;
diff --git a/src/charactermanaj/ui/ExportWizardDialog.java b/src/charactermanaj/ui/ExportWizardDialog.java
index d0912b0..49ccaf4 100644
--- a/src/charactermanaj/ui/ExportWizardDialog.java
+++ b/src/charactermanaj/ui/ExportWizardDialog.java
@@ -320,13 +320,6 @@ public class ExportWizardDialog extends JDialog {
protected boolean isComplete() {
- if (basicPanel.isExportSubset() && !basicPanel.isExportPartsImages()
- && !basicPanel.isExportPresets()
- && !basicPanel.isExportSamplePicture()) {
- // ãµãã»ãããæå®ããå ´åããã¼ãã¤ã¡ã¼ã¸ããã¼ãã»ãããã¾ãã¯ãµã³ãã«ãã¯ãã£ã®ããããã¯ã¨ã¯ã¹ãã¼ãããå¿
è¦ããã.
- return false;
- }
-
if (basicPanel.isExportPartsImages()) {
if (partsSelectPanel.getSelectedCount() == 0) {
// ãã¼ãã¤ã¡ã¼ã¸ã®ã¨ã¯ã¹ãã¼ããæå®ããå ´åãã¨ã¯ã¹ãã¼ããããã¼ãã®é¸æã¯å¿
é
@@ -405,7 +398,6 @@ public class ExportWizardDialog extends JDialog {
boolean exportSamplePicture = basicPanel.isExportSamplePicture();
boolean exportCharacterData = true;
boolean exportPartsImages = basicPanel.isExportPartsImages();
- boolean exportSubset = basicPanel.isExportSubset();
// åºæ¬æ
å ±ãè¨å®ãã.
cd.setAuthor(basicPanel.getAuthor());
@@ -416,7 +408,6 @@ public class ExportWizardDialog extends JDialog {
exportProp.setProperty(ExportInfoKeys.EXPORT_PRESETS, Boolean.toString(exportPresets));
exportProp.setProperty(ExportInfoKeys.EXPORT_SAMPLE_PICTURE, Boolean.toString(exportSamplePicture));
exportProp.setProperty(ExportInfoKeys.EXPORT_CHARACTER_DATA, Boolean.toString(exportCharacterData));
- exportProp.setProperty(ExportInfoKeys.EXPORT_SUBSET, Boolean.toString(exportSubset));
exportProp.setProperty(ExportInfoKeys.EXPORT_PARTS_IMAGES, Boolean.toString(exportPartsImages));
exportProp.setProperty(ExportInfoKeys.EXPORT_TIMESTAMP, Long.toString(System.currentTimeMillis()));
@@ -497,8 +488,6 @@ interface ExportInformationResolver extends ExportResolverBase {
BufferedImage getSamplePicture();
- boolean isExportSubset();
-
boolean isExportSamplePicture();
boolean isExportPartsImages();
@@ -558,8 +547,6 @@ class ExportInformationPanel extends AbstractImportPanel implements ExportInform
private JCheckBox chkSampleImage;
- private JCheckBox chkExportSubset;
-
protected ExportInformationPanel(final CharacterData characterData, final BufferedImage samplePicture) {
@@ -612,41 +599,34 @@ class ExportInformationPanel extends AbstractImportPanel implements ExportInform
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridheight = 1;
- gbc.gridwidth = 2;
+ gbc.gridwidth = 1;
gbc.weightx = 0.;
gbc.weighty = 0.;
gbc.insets = new Insets(3, 3, 3, 3);
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.BOTH;
- chkExportSubset = new JCheckBox(strings.getProperty("exportSubset"));
- commentPanel.add(chkExportSubset, gbc);
-
- gbc.gridx = 0;
- gbc.gridy = 1;
- gbc.gridheight = 1;
- gbc.gridwidth = 1;
- gbc.weightx = 0.;
- gbc.weighty = 0.;
commentPanel.add(new JLabel(strings.getProperty("author"), JLabel.RIGHT), gbc);
gbc.gridx = 1;
- gbc.gridy = 1;
+ gbc.gridy = 0;
gbc.gridwidth = 1;
gbc.weightx = 1.;
+ gbc.weighty = 0.;
txtAuthor = new JTextField();
commentPanel.add(txtAuthor, gbc);
gbc.gridx = 0;
- gbc.gridy = 2;
+ gbc.gridy = 1;
gbc.gridwidth = 1;
gbc.gridheight = 1;
gbc.weightx = 0.;
+ gbc.weighty = 0.;
commentPanel.add(new JLabel(strings.getProperty("description"), JLabel.RIGHT), gbc);
gbc.gridx = 1;
- gbc.gridy = 2;
+ gbc.gridy = 1;
gbc.gridwidth = 1;
- gbc.gridheight = 5;
+ gbc.gridheight = 2;
gbc.weighty = 1.;
gbc.weightx = 1.;
txtDescription = new JTextArea();
@@ -706,7 +686,6 @@ class ExportInformationPanel extends AbstractImportPanel implements ExportInform
chkPartsImages.addActionListener(modListener);
chkPresets.addActionListener(modListener);
chkSampleImage.addActionListener(modListener);
- chkExportSubset.addActionListener(modListener);
}
protected void updateSamplePicture() {
@@ -730,18 +709,12 @@ class ExportInformationPanel extends AbstractImportPanel implements ExportInform
String description = characterData.getDescription();
txtAuthor.setText(author == null ? "" : author);
txtDescription.setText(description == null ? "" : description);
-
- chkExportSubset.setSelected(true);
}
public BufferedImage getSamplePicture() {
return samplePicture;
}
- public boolean isExportSubset() {
- return chkExportSubset.isSelected();
- }
-
public boolean isExportSamplePicture() {
return chkSampleImage.isSelected();
}
diff --git a/src/charactermanaj/ui/MainFrame.java b/src/charactermanaj/ui/MainFrame.java
index 7a408e9..b323d5c 100644
--- a/src/charactermanaj/ui/MainFrame.java
+++ b/src/charactermanaj/ui/MainFrame.java
@@ -11,7 +11,9 @@ import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Frame;
+import java.awt.GraphicsEnvironment;
import java.awt.Point;
+import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.dnd.DropTarget;
import java.awt.event.ActionEvent;
@@ -211,16 +213,59 @@ public class MainFrame extends JFrame {
return activedMainFrame;
}
+ public static void notifyImportedPartsOrFavorites(CharacterData cd,
+ CharacterData newCd, Component caller) throws IOException {
+ if (cd == null || newCd == null || caller == null) {
+ throw new IllegalArgumentException();
+ }
+
+ if (!cd.isValid() || !newCd.isValid()) {
+ // å¤æ´åãããã¯å¤æ´å¾ãç¡å¹ãªãã£ã©ã¯ã¿ã¼ãã¼ã¿ã§ããã°
+ // åæ ããå¿
è¦ãªã.
+ return;
+ }
+ logger.log(Level.INFO, "parts imported for active profiles: " + newCd);
+
+
+ if ( !cd.isSameStructure(newCd)) {
+ // ãã£ã©ã¯ã¿ã¼ãã¼ã¿ãã®ãã®ãå¤æ´ããã¦ããå ´å
+ notifyChangeCharacterData(cd, newCd, caller);
+
+ } else {
+ // ãã¼ãæ§æã¯å¤æ´ããã¦ããªãå ´å
+
+ // Frameã®ãã¡ããã¤ãã£ããªã½ã¼ã¹ã¨é¢é£ã¥ãããã¦ããã¢ã¯ãã£ããªãã¬ã¼ã ã調æ»
+ for (Frame frame : JFrame.getFrames()) {
+ if (frame.isDisplayable() && frame instanceof MainFrame) {
+ MainFrame mainFrame = (MainFrame) frame;
+ if (mainFrame.characterData == null || !mainFrame.characterData.isValid()) {
+ // ç¡å¹ãªãã£ã©ã¯ã¿ã¼ãã¼ã¿ãä¿æãã¦ããå ´åã¯ããã®ã¡ã¤ã³ãã¬ã¼ã ã¯å¦ç対象å¤
+ continue;
+ }
+ // ãã¼ãåã³ãæ°ã«å
¥ããååå¾ããå ´å.
+ caller.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ try {
+ mainFrame.reloadPartsAndFavorites(newCd, true);
+
+ } finally {
+ caller.setCursor(Cursor.getDefaultCursor());
+ }
+ }
+ }
+ }
+ }
/**
* ãã£ã©ã¯ã¿ã¼ãã¼ã¿ãå¤æ´ããããã¨ãéç¥ããã.
* @param cd ãã£ã©ã¯ã¿ã¼ãã¼ã¿(å¤æ´å)
* @param newCd ãã£ã©ã¯ã¿ã¼ãã¼ã¿(å¤æ´å¾)
+ * @param caller å¼ã³åºããã¨ã³ã³ãã¼ãã³ã(ã¦ã§ã¤ãã«ã¼ã½ã«è¡¨ç¤ºç¨)
* @param structureCompatible æ§é ãåä¸ã§ããã?
* @throws IOException æ°ãããã£ã©ã¯ã¿ã¼ãã¼ã¿ã®ãã¼ãã»ããã®ãã¼ãã«å¤±æããå ´å (ã¡ã¤ã³ãã¬ã¼ã ã¯å¤æ´ããã¦ãã¾ãã.)
*/
- public static void notifyChangeCharacterData(CharacterData cd, CharacterData newCd) throws IOException {
- if (cd == null || newCd == null) {
+ public static void notifyChangeCharacterData(CharacterData cd,
+ CharacterData newCd, Component caller) throws IOException {
+ if (cd == null || newCd == null || caller == null) {
throw new IllegalArgumentException();
}
@@ -229,45 +274,54 @@ public class MainFrame extends JFrame {
// åæ ããå¿
è¦ãªã.
return;
}
+ logger.log(Level.INFO, "change active profile: " + newCd);
if (!ProfileListManager.isUsingCharacterData(cd)) {
// 使ç¨ä¸ã®ãããã¡ã¤ã«ã§ã¯ãªãã®ã§ä½ãããªã.
return;
}
-
- // ãã£ã©ã¯ã¿ã¼ãã¼ã¿ããã¾ã èªã¿è¾¼ã¾ãã¦ããªããã°èªã¿è¾¼ã.
- if (!newCd.isPartsLoaded()) {
- ProfileListManager.loadCharacterData(newCd);
- ProfileListManager.loadFavorites(newCd);
- }
- // Frameã®ãã¡ããã¤ãã£ããªã½ã¼ã¹ã¨é¢é£ã¥ãããã¦ããã¢ã¯ãã£ããªãã¬ã¼ã ã調æ»
- for (Frame frame : JFrame.getFrames()) {
- if (frame.isDisplayable() && frame instanceof MainFrame) {
- MainFrame mainFrame = (MainFrame) frame;
- if (mainFrame.characterData == null || !mainFrame.characterData.isValid()) {
- // ç¡å¹ãªãã£ã©ã¯ã¿ã¼ãã¼ã¿ãä¿æãã¦ããå ´åã¯ããã®ã¡ã¤ã³ãã¬ã¼ã ã¯å¦ç対象å¤
- continue;
- }
-
- // ã¡ã¤ã³ãã¬ã¼ã ãä¿æãã¦ãããã£ã©ã¯ã¿ã¼ãã¼ã¿ã®docbaseã¨
- // å¤æ´å¯¾è±¡ã¨ãªã£ããã£ã©ã¯ã¿ã¼ãã¼ã¿ã®docbaseãçãããã°ãã¡ã¤ã³ãã¬ã¼ã ãæ´æ°ããå¿
è¦ããã.
- String docbaseOrg = cd.getDocBase().toString();
- String docbaseMine = mainFrame.characterData.getDocBase().toString();
- if (docbaseOrg.equals(docbaseMine)) {
- mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- try {
- // ç¾å¨æ
å ±ã®ä¿å
- mainFrame.saveWorkingSet();
-
- // ç»é¢æ§æã®åæ§ç¯
- mainFrame.initComponent(newCd);
+ caller.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ try {
+ // ãã£ã©ã¯ã¿ã¼ãã¼ã¿ããã¾ã èªã¿è¾¼ã¾ãã¦ããªããã°èªã¿è¾¼ã.
+ if (!newCd.isPartsLoaded()) {
+ ProfileListManager.loadCharacterData(newCd);
+ ProfileListManager.loadFavorites(newCd);
+ }
+
+ // Frameã®ãã¡ããã¤ãã£ããªã½ã¼ã¹ã¨é¢é£ã¥ãããã¦ããã¢ã¯ãã£ããªãã¬ã¼ã ã調æ»
+ for (Frame frame : JFrame.getFrames()) {
+ if (frame.isDisplayable() && frame instanceof MainFrame) {
+ MainFrame mainFrame = (MainFrame) frame;
+ if (mainFrame.characterData == null || !mainFrame.characterData.isValid()) {
+ // ç¡å¹ãªãã£ã©ã¯ã¿ã¼ãã¼ã¿ãä¿æãã¦ããå ´åã¯ããã®ã¡ã¤ã³ãã¬ã¼ã ã¯å¦ç対象å¤
+ continue;
+ }
- } finally {
- mainFrame.setCursor(Cursor.getDefaultCursor());
+ // ã¡ã¤ã³ãã¬ã¼ã ãä¿æãã¦ãããã£ã©ã¯ã¿ã¼ãã¼ã¿ã®docbaseã¨
+ // å¤æ´å¯¾è±¡ã¨ãªã£ããã£ã©ã¯ã¿ã¼ãã¼ã¿ã®docbaseãçãããã°ãã¡ã¤ã³ãã¬ã¼ã ãæ´æ°ããå¿
è¦ããã.
+ String docbaseOrg = cd.getDocBase().toString();
+ String docbaseMine = mainFrame.characterData.getDocBase().toString();
+ if (docbaseOrg.equals(docbaseMine)) {
+ mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ try {
+ // ç¾å¨æ
å ±ã®ä¿å
+ mainFrame.saveWorkingSet();
+
+ // ç»é¢æ§æã®åæ§ç¯
+ mainFrame.initComponent(newCd);
+
+ } finally {
+ if (mainFrame != caller) {
+ mainFrame.setCursor(Cursor.getDefaultCursor());
+ }
+ }
}
}
}
+
+ } finally {
+ caller.setCursor(Cursor.getDefaultCursor());
}
}
@@ -303,60 +357,153 @@ public class MainFrame extends JFrame {
* @param characterData ãã£ã©ã¯ã¿ã¼ãã¼ã¿
*/
public MainFrame(CharacterData characterData) {
- if (characterData == null) {
- throw new IllegalArgumentException();
- }
-
- setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- onCloseProfile();
+ try {
+ if (characterData == null) {
+ throw new IllegalArgumentException();
}
- @Override
- public void windowClosed(WindowEvent e) {
- imageBuilder.stop();
+
+ setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+ addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent e) {
+ onCloseProfile();
+ }
+ @Override
+ public void windowClosed(WindowEvent e) {
+ stopAgents();
+ }
+ @Override
+ public void windowActivated(WindowEvent e) {
+ setActivedMainFrame(MainFrame.this);
+ }
+ @Override
+ public void windowOpened(WindowEvent e) {
+ // do nothing.
+ }
+ });
+
+ icon = UIHelper.getInstance().getImage("icons/icon.png");
+ setIconImage(icon);
+
+ // ç»é¢ã³ã³ãã¼ãã³ãä½æ
+ initComponent(characterData);
+ JMenuBar menuBar = createMenuBar();
+ setJMenuBar(menuBar);
+
+ // ã¡ã¤ã³ã¹ã¯ãªã¼ã³ãµã¤ãºãåå¾ãã.
+ GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ Rectangle desktopSize = genv.getMaximumWindowBounds(); // ã¡ã¤ã³ã¹ã¯ãªã¼ã³ã®ãµã¤ãº(ãã¹ã¯ãããé åã®ã¿)
+ logger.log(Level.INFO, "desktopSize=" + desktopSize);
+
+ Dimension imageSize = characterData.getImageSize();
+ // ç»åãµã¤ãº300x400ãåºæºãµã¤ãºã¨ãã¦ããã以ä¸ã«ã¯ãªããªã.
+ // ã¢ããªã±ã¼ã·ã§ã³è¨å®ã®æ大ãµã¤ãºä»¥ä¸ã®å ´åã¯ã¦ã£ã³ãã¦ãµã¤ãºã¯åºå®ãã¦ã¹ã¯ãã¼ã«ãã¼ã«ä»»ãã
+ AppConfig appConfig = AppConfig.getInstance();
+ int maxWidth = min(desktopSize.width, appConfig.getMainFrameMaxWidth());
+ int maxHeight = min(desktopSize.height, appConfig.getMainFrameMaxHeight());
+ int imageWidth = min(maxWidth, max(300, imageSize != null ? imageSize.width : 0));
+ int imageHeight = min(maxHeight, max(400, imageSize != null ? imageSize.height : 0));
+ // 300x400ã®ç»åã®å ´åã«ã¡ã¤ã³ãã¬ã¼ã ã600x550ã ã¨ã¡ããã©ããæã.
+ // ãã以ä¸å¤§ããç»åã®å ´åã¯å¢ããåã ããã¬ã¼ã ã大ãããã¦ãã.
+ setSize(imageWidth - 300 + 600, imageHeight - 400 + 550);
+
+ // 次å表示æã«ãã©ãããã©ã¼ã åºæä½ç½®ã«è¡¨ç¤ºããããã«äºç´
+ setLocationByPlatform(true);
+
+ } catch (RuntimeException ex) {
+ logger.log(Level.SEVERE, "ã¡ã¤ã³ãã¬ã¼ã ã®æ§ç¯ä¸ã«äºæãã¬ä¾å¤ãçºçãã¾ããã", ex);
+ dispose(); // ã³ã³ã¹ãã©ã¯ã¿ãå¼ã°ããæç¹ã§JFrameã¯æ§ç¯æ¸ã¿ãªã®ã§disposeã®å¿
è¦ããã.
+ throw ex;
+ } catch (Error ex) {
+ logger.log(Level.SEVERE, "ã¡ã¤ã³ãã¬ã¼ã ã®æ§ç¯ä¸ã«è´å½çãªä¾å¤ãçºçãã¾ããã", ex);
+ dispose(); // ã³ã³ã¹ãã©ã¯ã¿ãå¼ã°ããæç¹ã§JFrameã¯æ§ç¯æ¸ã¿ãªã®ã§disposeã®å¿
è¦ããã.
+ throw ex;
+ }
+ }
+
+ /**
+ * ã¡ã¤ã³ãã¬ã¼ã ã表示ãã.
+ * ãã¹ã¯ãããé åããã¯ã¿åºããå ´åã¯ä½ç½®ãè£æ£ãã.
+ */
+ public void showMainFrame() {
+ // ã¡ã¤ã³ã¹ã¯ãªã¼ã³ãµã¤ãºãåå¾ãã.
+ GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ Rectangle desktopSize = genv.getMaximumWindowBounds(); // ã¡ã¤ã³ã¹ã¯ãªã¼ã³ã®ãµã¤ãº(ãã¹ã¯ãããé åã®ã¿)
+ logger.log(Level.INFO, "desktopSize=" + desktopSize);
+
+ // ãã©ãããã©ã¼ã åºæã®ä½ç½®ãããã§è¡¨ç¤ºãã.
+ // 表示ããçµæãã¯ã¿åºãã¦ããå ´åã¯0,0ã«è£æ£ãã.
+ setVisible(true);
+ Point loc = getLocation();
+ logger.log(Level.INFO, "windowLocation=" + loc);
+ Dimension windowSize = getSize();
+ if (loc.y + windowSize.height >= desktopSize.height) {
+ loc.y = 0;
+ }
+ if (loc.x + windowSize.width >= desktopSize.width) {
+ loc.x = 0;
+ }
+ if (loc.x == 0 || loc.y == 0) {
+ setLocation(loc);
+ }
+
+ // ãã¹ã¯ãããããã大ããå ´åã¯å°ãããã.
+ boolean resize = false;
+ Dimension dim = getSize();
+ if (dim.height > desktopSize.height) {
+ dim.height = desktopSize.height;
+ resize = true;
+ }
+ if (dim.width > desktopSize.width) {
+ dim.width = desktopSize.width;
+ resize = true;
+ }
+ if (resize) {
+ setSize(dim);
+ }
+ }
+
+ /**
+ * ãã®ã¡ã¤ã³ãã¬ã¼ã ã«é¢é£ã¥ãããã¦ããã¨ã¼ã¸ã§ã³ãã¹ã¬ãããåæ¢ãã¾ã.
+ * ãã§ã«åæ¢ãã¦ããå ´åã¯ä½ããã¾ããã
+ */
+ protected void stopAgents() {
+ // ã¨ã¼ã¸ã§ã³ããåæ¢
+ if (watchAgent != null) {
+ try {
watchAgent.stop();
+
+ } catch (Throwable ex) {
+ logger.log(Level.SEVERE, "ãã©ã«ãç£è¦ã¹ã¬ããã®åæ¢ã«å¤±æãã¾ããã", ex);
}
- @Override
- public void windowActivated(WindowEvent e) {
- setActivedMainFrame(MainFrame.this);
- }
- @Override
- public void windowOpened(WindowEvent e) {
- // do nothing.
+ watchAgent = null;
+ }
+ // ã¤ã¡ã¼ã¸ãã«ããåæ¢
+ if (imageBuilder != null) {
+ try {
+ imageBuilder.stop();
+
+ } catch (Throwable ex) {
+ logger.log(Level.SEVERE, "éåæã¤ã¡ã¼ã¸ãã«ãã¹ã¬ããã®åæ¢ã«å¤±æãã¾ããã", ex);
}
- });
+ imageBuilder = null;
+ }
+ }
- icon = UIHelper.getInstance().getImage("icons/icon.png");
- setIconImage(icon);
-
- // ç»é¢ã³ã³ãã¼ãã³ãä½æ
- initComponent(characterData);
- JMenuBar menuBar = createMenuBar();
- setJMenuBar(menuBar);
-
- Dimension imageSize = characterData.getImageSize();
- // ç»åãµã¤ãº300x400ãåºæºãµã¤ãºã¨ãã¦ããã以ä¸ã«ã¯ãªããªã.
- // ã¢ããªã±ã¼ã·ã§ã³è¨å®ã®æ大ãµã¤ãºä»¥ä¸ã®å ´åã¯ã¦ã£ã³ãã¦ãµã¤ãºã¯åºå®ãã¦ã¹ã¯ãã¼ã«ãã¼ã«ä»»ãã
- AppConfig appConfig = AppConfig.getInstance();
- int maxWidth = appConfig.getMainFrameMaxWidth();
- int maxHeight = appConfig.getMainFrameMaxHeight();
- int imageWidth = min(maxWidth, max(300, imageSize != null ? imageSize.width : 0));
- int imageHeight = min(maxHeight, max(400, imageSize != null ? imageSize.height : 0));
- // 300x400ã®ç»åã®å ´åã«ã¡ã¤ã³ãã¬ã¼ã ã600x550ã ã¨ã¡ããã©ããæã.
- // ãã以ä¸å¤§ããç»åã®å ´åã¯å¢ããåã ããã¬ã¼ã ã大ãããã¦ãã.
- setSize(imageWidth - 300 + 600, imageHeight - 400 + 550);
-
- //setLocationRelativeTo(null);
- setLocationByPlatform(true);
+ /**
+ * ã¡ã¤ã³ãã¬ã¼ã ãç ´æ£ãã¾ã.
+ */
+ @Override
+ public void dispose() {
+ stopAgents();
+ super.dispose();
}
/**
* ç»é¢ã³ã³ãã¼ãã³ããè¨å®ãã¾ã.
* ãã§ã«è¨å®ããã¦ããå ´åã¯ä¸æ¦åé¤ãããã®ã¡ã«åä½æããã¾ã.
*/
- private void initComponent(CharacterData characterData) {
+ private synchronized void initComponent(CharacterData characterData) {
CharacterData oldCd;
synchronized (this) {
@@ -388,15 +535,9 @@ public class MainFrame extends JFrame {
// ããã©ã«ãã®ãã¼ãã»ãã表示å
defaultPartsSetTitle = strings.getProperty("defaultPartsSetTitle");
-
- // ã¨ã¼ã¸ã§ã³ããåæ¢
- if (watchAgent != null) {
- watchAgent.stop();
- }
- // ã¤ã¡ã¼ã¸ãã«ããåæ¢
- if (imageBuilder != null) {
- imageBuilder.stop();
- }
+
+ // ã¨ã¼ã¸ã§ã³ãã®åæ¢
+ stopAgents();
// ã³ã³ãã¼ãã³ãé
ç½®
Container contentPane = getContentPane();
@@ -521,7 +662,9 @@ public class MainFrame extends JFrame {
// ä¿åããã¦ããã¯ã¼ãã³ã°ã»ããã復å
ãã.
// 復å
ã§ããªãã£ãå ´åã¯ãã¼ãã»ãããåæé¸æãã.
if ( !loadWorkingSet()) {
- showDefaultParts(true);
+ if (showDefaultParts(true)) {
+ requestPreview();
+ }
}
// é¸æããã¦ãããã¼ããè¦ããç¶æ
ã«ãã
@@ -586,9 +729,11 @@ public class MainFrame extends JFrame {
* ãã¼ããã¼ã¿ããªãã¼ãããåã«ãã´ãªã®ãã¼ãä¸è¦§ãå表示ããããã¬ãã¥ã¼ãæ´æ°ãã.
*/
protected void onDetectPartsImageChange() {
- if (characterData.reloadPartsData()) {
- partsSelectionManager.loadParts();
- requestPreview();
+ try {
+ reloadPartsAndFavorites(null, true);
+
+ } catch (IOException ex) {
+ logger.log(Level.SEVERE, "parts reload failed. " + characterData, ex);
}
}
@@ -602,59 +747,75 @@ public class MainFrame extends JFrame {
/**
* ããã©ã«ããã¼ããé¸æãã.
* ããã©ã«ããã¼ãããªããã°ãæ°ã«å
¥ãã®æåã®ãã®ãé¸æãã.
- * ããããªããã°ç©ºã¨ãã¦è¡¨ç¤ºãã.
+ * ããããªããã°ç©ºã¨ãã¦è¡¨ç¤ºãã.
+ * ãã¼ãã®é©ç¨ã«å¤±æããå ´åã¯falseãè¿ãã¾ã.(ä¾å¤ã¯è¿ããã¾ãã.)
* @param force ãã§ã«é¸æããã£ã¦ãé¸æããªããå ´åã¯trueãfalseã®å ´åã¯é¸æãããã°ä½ãããªã.
- * @return ãã¼ãé¸æãããªãã£ãå ´åãforce=trueã®å ´åã¯å¸¸ã«trueã¨ãªãã¾ãã
+ * @return ãã¼ãé¸æãããå ´åãforce=trueã®å ´åã¯ã¨ã©ã¼ããªããã°å¸¸ã«trueã¨ãªãã¾ãã
*/
protected boolean showDefaultParts(boolean force) {
- if (!force) {
- PartsSet sel = partsSelectionManager.createPartsSet();
- if (!sel.isEmpty()) {
- // å¼·å¶é¸æã§ãªãå ´åããã§ã«é¸ææ¸ã¿ã®ãã¼ããããã°ä½ãããªã.
- return false;
+ try {
+ if (!force) {
+ // ç¾å¨é¸æä¸ã®ãã¼ããåå¾ãã.(ãªããã°ç©º)
+ PartsSet sel = partsSelectionManager.createPartsSet();
+ if (!sel.isEmpty()) {
+ // å¼·å¶é¸æã§ãªãå ´åããã§ã«é¸ææ¸ã¿ã®ãã¼ããããã°ä½ãããªã.
+ return false;
+ }
}
- }
-
- // ããã©ã«ãã®ãã¼ãã»ãããåå¾ãã
- String defaultPresetId = characterData.getDefaultPartsSetId();
- PartsSet partsSet = null;
- if (defaultPresetId != null) {
- partsSet = characterData.getPartsSets().get(defaultPresetId);
- }
-
- // ããã©ã«ãã®ãã¼ãã»ããããªããã°ããæ°ã«å
¥ãã®æåãé¸æãã.
- if (partsSet == null) {
- List partssets = getPartsSetList();
- if (!partssets.isEmpty()) {
- partsSet = partssets.get(0);
+
+ // ããã©ã«ãã®ãã¼ãã»ãããåå¾ãã
+ String defaultPresetId = characterData.getDefaultPartsSetId();
+ PartsSet partsSet = null;
+ if (defaultPresetId != null) {
+ partsSet = characterData.getPartsSets().get(defaultPresetId);
}
- }
+
+ // ããã©ã«ãã®ãã¼ãã»ããããªããã°ããæ°ã«å
¥ãã®æåãé¸æãã.
+ if (partsSet == null) {
+ List partssets = getPartsSetList();
+ if (!partssets.isEmpty()) {
+ partsSet = partssets.get(0);
+ }
+ }
+
+ // ãã¼ãã»ãããããã°ãããã表示è¦æ±ãã.
+ // ãã¼ãã»ããããªããã°ã«ã©ã¼ãã¤ã¢ãã°ãåæåããã®ã¿
+ if (partsSet == null) {
+ partsColorCoordinator.initColorDialog();
- // ãã¼ãã»ãããããã°ãããã表示è¦æ±ãã.
- // ãã¼ãã»ããããªããã°ã«ã©ã¼ãã¤ã¢ãã°ãåæåããã®ã¿
- if (partsSet == null) {
- partsColorCoordinator.initColorDialog();
- requestPreview();
- } else {
- selectPresetParts(partsSet);
+ } else {
+ selectPresetParts(partsSet);
+ }
+
+ } catch (Exception ex) {
+ logger.log(Level.WARNING, "ãã¼ãã®ããã©ã«ãé©ç¨ã«å¤±æãã¾ããã", ex);
+ return false;
}
-
return true;
}
/**
- * ããªã»ãããé©ç¨ããã£ã©ã¯ã¿ã¼ã¤ã¡ã¼ã¸ãåæ§ç¯ãã¾ã.
- * @param presetParts
+ * ããªã»ãããé©ç¨ããã£ã©ã¯ã¿ã¼ã¤ã¡ã¼ã¸ãåæ§ç¯ãã¾ã.
+ * å®è¡æã¨ã©ã¼ã¯ç»é¢ã®ã¬ãã¼ãããã¾ã.
+ * @param presetParts ãã¼ãã»ãã, nullã®å ´åã¯ä½ãããªã.
*/
protected void selectPresetParts(PartsSet presetParts) {
- // æå¾ã«ä½¿ç¨ããããªã»ããã¨ãã¦è¨æ¶ãã.
- lastUsePresetParts = presetParts;
- // ããªã»ãããã¼ãã§é¸æãå¤ãã
- partsSelectionManager.selectPartsSet(presetParts);
- // ã«ã©ã¼ããã«ãé¸æããã¦ããã¢ã¤ãã ããã¨ã«åè¨å®ãã
- partsColorCoordinator.initColorDialog();
- // å表示
- requestPreview();
+ if (presetParts == null) {
+ return;
+ }
+ try {
+ // æå¾ã«ä½¿ç¨ããããªã»ããã¨ãã¦è¨æ¶ãã.
+ lastUsePresetParts = presetParts;
+ // ããªã»ãããã¼ãã§é¸æãå¤ãã
+ partsSelectionManager.selectPartsSet(presetParts);
+ // ã«ã©ã¼ããã«ãé¸æããã¦ããã¢ã¤ãã ããã¨ã«åè¨å®ãã
+ partsColorCoordinator.initColorDialog();
+ // å表示
+ requestPreview();
+
+ } catch (Exception ex) {
+ ErrorMessageHelper.showErrorDialog(this, ex);
+ }
}
/**
@@ -867,10 +1028,7 @@ public class MainFrame extends JFrame {
try {
MainFrame main2 = ProfileListManager.openProfile(this);
if (main2 != null) {
- Point pt = getLocation();
- pt.x += 100;
- main2.setLocation(pt);
- main2.setVisible(true);
+ main2.showMainFrame();
}
} catch (Exception ex) {
@@ -964,13 +1122,7 @@ public class MainFrame extends JFrame {
CharacterData cd = this.characterData;
CharacterData newCd = ProfileListManager.editProfile(this, cd);
if (newCd != null) {
- setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- try {
- MainFrame.notifyChangeCharacterData(cd, newCd); //TODO:éè¤
-
- } finally {
- setCursor(Cursor.getDefaultCursor());
- }
+ MainFrame.notifyChangeCharacterData(cd, newCd, this);
}
} catch (Exception ex) {
@@ -1104,49 +1256,62 @@ public class MainFrame extends JFrame {
return;
}
- // ç£è¦ã¹ã¬ãããåæ¢ãã¦ããã¤ã³ãã¼ãå¦çãå§ãã
- boolean stopped = watchAgent.stop();
try {
// ã¤ã³ãã¼ãã¦ã£ã¶ã¼ãã®å®è¡
ImportWizardDialog importWizDialog = new ImportWizardDialog(this, characterData, initFiles);
importWizDialog.setVisible(true);
if (importWizDialog.getExitCode() == ImportWizardDialog.EXIT_PROFILE_UPDATED) {
- try {
- setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- try {
- // ã¤ã³ãã¼ããå®è¡ãããå ´åããã¼ããã¼ã¿ããªãã¼ããã.
- if (characterData.reloadPartsData()) {
- partsSelectionManager.loadParts();
-
- // ãã¼ããã¼ã¿ãå¤æ´ãããå¯è½æ§ãããã®ã§ã
- // ç£è¦ç¶æ
ããªã»ãããã¦ããåéããããã«ãã.
- watchAgent.reset();
- }
-
- // ãæ°ã«å
¥ãããªãã¼ããã.
- CharacterDataPersistent persiste = CharacterDataPersistent.getInstance();
- persiste.loadFavorites(characterData);
-
- } finally {
- setCursor(Cursor.getDefaultCursor());
- }
-
- } catch (Exception ex) {
- ErrorMessageHelper.showErrorDialog(this, ex);
- }
-
- // å表示
- if (showDefaultParts(false)) {
- requestPreview();
- }
+ CharacterData importedCd = importWizDialog.getImportedCharacterData();
+ notifyImportedPartsOrFavorites(characterData, importedCd, this);
}
- } finally {
- // ç£è¦ã¹ã¬ãããåéãã.
- if (stopped) {
- watchAgent.start();
+ } catch (Exception ex) {
+ ErrorMessageHelper.showErrorDialog(this, ex);
+ }
+ }
+
+ /**
+ * ãã¼ãã¨ãæ°ã«å
¥ãããªãã¼ããã.
+ * ã¾ã ãã¼ãããã¦ããªãå ´åã¯ãããã«ãã¼ããã.
+ * å¼æ°newCdãæå®ããã¦ããå ´åã¯ãç¾å¨ã®ãã£ã©ã¯ã¿ã¼å®ç¾©ã®èª¬ææãæ´æ°ãã.
+ * (説ææã®æ´æ°ä»¥å¤ã«ã¯ä½¿ç¨ãããªã.)
+ *
+ * @param newCd
+ * 説æææ´æ°ã®ããã®æ´æ°ããããã£ã©ã¯ã¿ã¼ãã¼ã¿ãæå®ãããnullå¯
+ * @param forceRepaint
+ * å¿
ãåæç»ããå ´å
+ * @throws IOException
+ * 失æ
+ */
+ protected synchronized void reloadPartsAndFavorites(CharacterData newCd,
+ boolean forceRepaint) throws IOException {
+ if (newCd != null) {
+ // (ã¤ã³ãã¼ãç»é¢ã§ã¯èª¬ææã®ã¿æ´æ°ããã®ã§ãããã ãåå¾)
+ characterData.setDescription(newCd.getDescription());
+ }
+
+ if ( !characterData.isPartsLoaded()) {
+ // ãã£ã©ã¯ã¿ã¼ãã¼ã¿ããã¾ã èªã¿è¾¼ã¾ãã¦ããªããã°èªã¿è¾¼ã.
+ ProfileListManager.loadCharacterData(characterData);
+ ProfileListManager.loadFavorites(characterData);
+ partsSelectionManager.loadParts();
+
+ } else {
+ // ãã¼ããã¼ã¿ããªãã¼ããã.
+ if (characterData.reloadPartsData()) {
+ partsSelectionManager.loadParts();
}
+
+ // ãæ°ã«å
¥ãããªãã¼ããã.
+ CharacterDataPersistent persiste = CharacterDataPersistent.getInstance();
+ persiste.loadFavorites(characterData);
+ notifyChangeFavorites(characterData);
+ }
+
+ // ç¾å¨é¸æããã¦ãããã¼ãã»ããããªãå ´åã¯ããã©ã«ãã®ãã¼ãã»ãããé¸æãã.
+ if (showDefaultParts(false) || forceRepaint) {
+ requestPreview();
}
}
@@ -1344,16 +1509,20 @@ public class MainFrame extends JFrame {
// ç¾å¨ã®ãã¼ãè²æ
å ±ã«ã¯ã¼ãã³ã°ã»ããã§ä¿åããå
容ãè¨å®ãã.
Map partsColorInfoMap = characterData.getPartsColorManager().getPartsColorInfoMap();
- for (Map.Entry entry : workingSet.getPartsColorInfoMap().entrySet()) {
- PartsIdentifier partsIdentifier = entry.getKey();
- PartsColorInfo partsColorInfo = entry.getValue();
- partsColorInfoMap.put(partsIdentifier, partsColorInfo);
+ Map workingPartsColorInfoMap = workingSet.getPartsColorInfoMap();
+ if (workingPartsColorInfoMap != null) {
+ for (Map.Entry entry : workingPartsColorInfoMap.entrySet()) {
+ PartsIdentifier partsIdentifier = entry.getKey();
+ PartsColorInfo partsColorInfo = entry.getValue();
+ partsColorInfoMap.put(partsIdentifier, partsColorInfo);
+ }
}
// é¸æããã¦ãããã¼ãã®å¾©å
PartsSet partsSet = workingSet.getPartsSet();
if (partsSet != null) {
- selectPresetParts(partsSet.createCompatible(characterData));
+ partsSet = partsSet.createCompatible(characterData);
+ selectPresetParts(partsSet);
// æå¾ã«é¸æãããæ°ã«å
¥ãæ
å ±ã®å¾©å
PartsSet lastUsePresetParts = workingSet.getLastUsePresetParts();
@@ -1599,9 +1768,9 @@ public class MainFrame extends JFrame {
}
}),
null,
- new MenuDataFactory("file.manageParts", new ActionListener() {
+ new MenuDataFactory("file.editprofile", new ActionListener() {
public void actionPerformed(ActionEvent e) {
- onManageParts();
+ onEditProfile();
}
}),
new MenuDataFactory("file.opendir", new ActionListener() {
@@ -1609,11 +1778,6 @@ public class MainFrame extends JFrame {
onBrowseProfileDir();
}
}),
- new MenuDataFactory("file.editprofile", new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- onEditProfile();
- }
- }),
new MenuDataFactory("file.import", new MenuDataFactory[] {
new MenuDataFactory("file.importMe", new ActionListener() {
public void actionPerformed(ActionEvent e) {
@@ -1631,6 +1795,11 @@ public class MainFrame extends JFrame {
onExport();
};
}),
+ new MenuDataFactory("file.manageParts", new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ onManageParts();
+ }
+ }),
new MenuDataFactory("file.preferences", new ActionListener() {
public void actionPerformed(ActionEvent e) {
onPreferences();
diff --git a/src/charactermanaj/ui/MainFramePartialForMacOSX.java b/src/charactermanaj/ui/MainFramePartialForMacOSX.java
index b96a2bc..88dbc54 100644
--- a/src/charactermanaj/ui/MainFramePartialForMacOSX.java
+++ b/src/charactermanaj/ui/MainFramePartialForMacOSX.java
@@ -12,6 +12,12 @@ import com.apple.eawt.Application;
import com.apple.eawt.ApplicationAdapter;
import com.apple.eawt.ApplicationEvent;
+/**
+ * Mac OS Xç¨ã®ã¡ã¤ã³ãã¬ã¼ã ãµãã¼ãã¯ã©ã¹.
+ * ã¹ã¯ãªã¼ã³ã¡ãã¥ã¼ã®ãã³ãã©ãªã©ãæ¥ç¶ãã¦ãã.
+ * @author seraphy
+ *
+ */
public class MainFramePartialForMacOSX {
/**
diff --git a/src/charactermanaj/ui/ProfileEditDialog.java b/src/charactermanaj/ui/ProfileEditDialog.java
index cfe9429..e9297b4 100644
--- a/src/charactermanaj/ui/ProfileEditDialog.java
+++ b/src/charactermanaj/ui/ProfileEditDialog.java
@@ -1158,8 +1158,8 @@ public class ProfileEditDialog extends JDialog {
newCd.setRev(persist.generateRev());
}
- } else {
- // æ°è¦ã§ã¯ãªããæ§é ãå¤æ´ããã¦ãããã¨ãéç¥ãã.
+ } else if ( !newCd.isUpperCompatibleStructure(original)){
+ // ä¸ä½äºæã®ãªãæ§é ãå¤æ´ããã¦ãããã¨ãéç¥ãã.
if (JOptionPane.showConfirmDialog(this,
strings.get("confirm.changestructre"),
strings.getProperty("confirm"),
diff --git a/src/charactermanaj/ui/ProfileSelectorDialog.java b/src/charactermanaj/ui/ProfileSelectorDialog.java
index 1a06c0a..a1b4ee0 100644
--- a/src/charactermanaj/ui/ProfileSelectorDialog.java
+++ b/src/charactermanaj/ui/ProfileSelectorDialog.java
@@ -745,13 +745,7 @@ public class ProfileSelectorDialog extends JDialog {
}
// ç¾å¨éãã¦ããã¡ã¤ã³ãã¬ã¼ã ã«å¯¾ãã¦ãã£ã©ã¯ã¿ã¼å®ç¾©ãå¤æ´ããããã¨ãéç¥ãã.
- setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- try {
- MainFrame.notifyChangeCharacterData(cd, newCd); //TODO:éè¤
-
- } finally {
- setCursor(Cursor.getDefaultCursor());
- }
+ MainFrame.notifyChangeCharacterData(cd, newCd, this);
// ãããã¡ã¤ã«ä¸è¦§ç»é¢ãæ´æ°ãã.
characterListModel.set(rowIndex, newCd);
@@ -853,61 +847,71 @@ public class ProfileSelectorDialog extends JDialog {
* ã¤ã³ãã¼ã
*/
protected void onProfileImport() {
- CharacterData selCd = (CharacterData) characterList.getSelectedValue();
-
- // é¸æãããããã¡ã¤ã«ãæ´æ°ããããæ°è¦ã«ãããã¡ã¤ã«ãä½æãããé¸æã§ããããã«ãã
- if (selCd != null) {
- final Properties strings = LocalizedResourcePropertyLoader
- .getInstance().getLocalizedProperties(STRINGS_RESOURCE);
-
- JPanel radioPanel = new JPanel(new BorderLayout());
- JRadioButton btnUpdate = new JRadioButton(strings.getProperty("importToUpdateProfile"));
- JRadioButton btnNew = new JRadioButton(strings.getProperty("importToCreateProfile"));
- ButtonGroup radios = new ButtonGroup();
- radios.add(btnUpdate);
- radios.add(btnNew);
- btnUpdate.setSelected(true);
- radioPanel.add(btnUpdate, BorderLayout.NORTH);
- radioPanel.add(btnNew, BorderLayout.SOUTH);
+ try {
+ CharacterData selCd = (CharacterData) characterList.getSelectedValue();
+
+ // é¸æãããããã¡ã¤ã«ãæ´æ°ããããæ°è¦ã«ãããã¡ã¤ã«ãä½æãããé¸æã§ããããã«ãã
+ if (selCd != null) {
+ final Properties strings = LocalizedResourcePropertyLoader
+ .getInstance().getLocalizedProperties(STRINGS_RESOURCE);
+
+ JPanel radioPanel = new JPanel(new BorderLayout());
+ JRadioButton btnUpdate = new JRadioButton(strings.getProperty("importToUpdateProfile"));
+ JRadioButton btnNew = new JRadioButton(strings.getProperty("importToCreateProfile"));
+ ButtonGroup radios = new ButtonGroup();
+ radios.add(btnUpdate);
+ radios.add(btnNew);
+ btnUpdate.setSelected(true);
+ radioPanel.add(btnUpdate, BorderLayout.NORTH);
+ radioPanel.add(btnNew, BorderLayout.SOUTH);
+
+ int ret = JOptionPane.showConfirmDialog(this, radioPanel,
+ strings.getProperty("confirmUpdateProfile"),
+ JOptionPane.OK_CANCEL_OPTION);
+ if (ret != JOptionPane.OK_OPTION) {
+ return;
+ }
- int ret = JOptionPane.showConfirmDialog(this, radioPanel,
- strings.getProperty("confirmUpdateProfile"),
- JOptionPane.OK_CANCEL_OPTION);
- if (ret != JOptionPane.OK_OPTION) {
- return;
- }
-
- if (btnNew.isSelected()) {
- // é¸æããã¦ããªããã¨ã«ãã.
- selCd = null;
+ if (btnNew.isSelected()) {
+ // é¸æããã¦ããªããã¨ã«ãã.
+ selCd = null;
+ }
}
- }
-
- // ãã£ã©ã¯ã¿ã¼ãã¼ã¿ããã¼ããç´ã.
- CharacterData cd;
- if (selCd != null) {
- cd = selCd.duplicateBasicInfo();
- try {
- ProfileListManager.loadCharacterData(cd);
- ProfileListManager.loadFavorites(cd);
-
- } catch (IOException ex) {
- ErrorMessageHelper.showErrorDialog(this, ex);
- // ç¶ç¶ãã.
+
+ // ãã£ã©ã¯ã¿ã¼ãã¼ã¿ããã¼ããç´ã.
+ CharacterData cd;
+ if (selCd != null) {
+ cd = selCd.duplicateBasicInfo();
+ try {
+ ProfileListManager.loadCharacterData(cd);
+ ProfileListManager.loadFavorites(cd);
+
+ } catch (IOException ex) {
+ ErrorMessageHelper.showErrorDialog(this, ex);
+ // ç¶ç¶ãã.
+ }
+ } else {
+ cd = null;
}
- } else {
- cd = null;
- }
-
- // ã¤ã³ãã¼ãã¦ã£ã¶ã¼ãã®å®è¡
- ImportWizardDialog importWizDialog = new ImportWizardDialog(this, cd);
- importWizDialog.setVisible(true);
-
- if (importWizDialog.getExitCode() == ImportWizardDialog.EXIT_PROFILE_CREATED) {
+
+ // ã¤ã³ãã¼ãã¦ã£ã¶ã¼ãã®å®è¡
+ ImportWizardDialog importWizDialog = new ImportWizardDialog(this, cd);
+ importWizDialog.setVisible(true);
+
CharacterData newCd = importWizDialog.getImportedCharacterData();
+ if (importWizDialog.getExitCode() == ImportWizardDialog.EXIT_PROFILE_CREATED) {
+
+ // ä½æããããããã¡ã¤ã«ãä¸è¦§ã«è¿½å ãã.
+ characterListModel.addElement(newCd);
+
+ } else if (importWizDialog.getExitCode() == ImportWizardDialog.EXIT_PROFILE_UPDATED) {
- // ä½æããããããã¡ã¤ã«ãä¸è¦§ã«è¿½å ãã.
- characterListModel.addElement(newCd);
+ // æ´æ°ããããããã¡ã¤ã«ãéç¥ãã
+ MainFrame.notifyImportedPartsOrFavorites(cd, newCd, this);
+ }
+
+ } catch (Exception ex) {
+ ErrorMessageHelper.showErrorDialog(this, ex);
}
}
diff --git a/src/charactermanaj/util/DesktopUtilities.java b/src/charactermanaj/util/DesktopUtilities.java
index 19ddf06..c80609c 100644
--- a/src/charactermanaj/util/DesktopUtilities.java
+++ b/src/charactermanaj/util/DesktopUtilities.java
@@ -165,12 +165,6 @@ public class DesktopUtilities {
*/
public static void browse(final Component parent, final String url, final String description) {
try {
- browse(new URI(url));
-
- } catch (Exception ex) {
- ErrorMessageHelper.showErrorDialog(parent, ex);
- }
- try {
URI helpURI = new URI(url);
if (!DesktopUtilities.browse(helpURI) ){
diff --git a/src/charactermanaj/util/UserDataFactory.java b/src/charactermanaj/util/UserDataFactory.java
index 1a7795c..b0d43ee 100644
--- a/src/charactermanaj/util/UserDataFactory.java
+++ b/src/charactermanaj/util/UserDataFactory.java
@@ -3,6 +3,8 @@ package charactermanaj.util;
import java.io.File;
import java.net.URI;
import java.util.UUID;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
@@ -10,6 +12,11 @@ import java.util.UUID;
* @author seraphy
*/
public class UserDataFactory {
+
+ /**
+ * ãã¬ã¼
+ */
+ private static final Logger logger = Logger.getLogger(UserDataFactory.class.getName());
/**
* ã·ã³ã°ã«ãã³
@@ -57,7 +64,8 @@ public class UserDataFactory {
// ãã©ã«ãããªããã°ä½æãã.
if (!userDataDir.exists()) {
- userDataDir.mkdirs();
+ boolean result = userDataDir.mkdirs();
+ logger.log(Level.INFO, "makeDir: " + userDataDir + " /succeeded=" + result);
}
return userDataDir;