From a10058fc7f4d3469a462c39ecdbce5cdbe103861 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Fri, 19 Sep 2008 20:19:08 -0700 Subject: [PATCH] Improved Cib Support. Reviewed by ross. --- AppKit/CPDocumentController.j | 12 +++---- AppKit/CPView.j | 2 +- AppKit/Cib/CPCib.j | 3 +- AppKit/Cib/_CPCibCustomObject.j | 2 +- AppKit/Cib/_CPCibKeyedUnarchiver.j | 34 +++++++++++++++++++ AppKit/Cib/_CPCibWindowTemplate.j | 2 +- AppKit/Platform/DOM/CPDOMDisplayServer.j | 4 +-- Tools/NibApp/HelloWorld.nib/info.nib | 5 ++- Tools/NibApp/HelloWorld.nib/keyedobjects.nib | Bin 4015 -> 4087 bytes 9 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 AppKit/Cib/_CPCibKeyedUnarchiver.j diff --git a/AppKit/CPDocumentController.j b/AppKit/CPDocumentController.j index 84fbd9d7a..80edb065b 100644 --- a/AppKit/CPDocumentController.j +++ b/AppKit/CPDocumentController.j @@ -100,18 +100,18 @@ var CPSharedDocumentController = nil; */ - (void)openUntitledDocumentOfType:(CPString)aType display:(BOOL)shouldDisplay { - var document = [self makeUntitledDocumentOfType:aType error:nil]; + var theDocument = [self makeUntitledDocumentOfType:aType error:nil]; - if (document) - [self addDocument:document]; + if (theDocument) + [self addDocument:theDocument]; if (shouldDisplay) { - [document makeWindowControllers]; - [document showWindows]; + [theDocument makeWindowControllers]; + [theDocument showWindows]; } - return document; + return theDocument; } /* diff --git a/AppKit/CPView.j b/AppKit/CPView.j index 8a90392db..481cce508 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -368,7 +368,7 @@ var DOMElementPrototype = nil, [aSubview removeFromSuperview]; - [aView _insertSubview:aView atIndex:index]; + [self _insertSubview:aView atIndex:index]; } /* @ignore */ diff --git a/AppKit/Cib/CPCib.j b/AppKit/Cib/CPCib.j index be630aedb..ee27f538d 100644 --- a/AppKit/Cib/CPCib.j +++ b/AppKit/Cib/CPCib.j @@ -26,6 +26,7 @@ import import "CPCustomView.j" import "_CPCibCustomObject.j" +import "_CPCibKeyedUnarchiver.j" import "_CPCibObjectData.j" import "_CPCibWindowTemplate.j" @@ -51,7 +52,7 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey"; - (BOOL)instantiateCibWithExternalNameTable:(CPDictionary)anExternalNameTable { - var unarchiver = [[CPKeyedUnarchiver alloc] initForReadingWithData:_data], + var unarchiver = [[_CPCibKeyedUnarchiver alloc] initForReadingWithData:_data], objectData = [unarchiver decodeObjectForKey:CPCibObjectDataKey]; if (!objectData || ![objectData isKindOfClass:[_CPCibObjectData class]]) diff --git a/AppKit/Cib/_CPCibCustomObject.j b/AppKit/Cib/_CPCibCustomObject.j index 56b633c9a..5064784d8 100644 --- a/AppKit/Cib/_CPCibCustomObject.j +++ b/AppKit/Cib/_CPCibCustomObject.j @@ -28,7 +28,7 @@ var _CPCibCustomObjectClassName = @"_CPCibCustomObjectClassName"; [aCoder encodeObject:_className forKey:_CPCibCustomObjectClassName]; } -- (id)awakeAfterUsingCoder:(CPCoder)aCoder +- (id)_cibInstantiate { var theClass = CPClassFromString(_className); diff --git a/AppKit/Cib/_CPCibKeyedUnarchiver.j b/AppKit/Cib/_CPCibKeyedUnarchiver.j new file mode 100644 index 000000000..f962d2be6 --- /dev/null +++ b/AppKit/Cib/_CPCibKeyedUnarchiver.j @@ -0,0 +1,34 @@ + +import + + +@implementation _CPCibKeyedUnarchiver : CPKeyedUnarchiver +{ +} + +- (id)decodeObjectForKey:(CPString)aKey +{ + var object = [super decodeObjectForKey:aKey]; + + if ([object respondsToSelector:@selector(_cibInstantiate)]) + { + var index = [[_plistObject objectForKey:aKey] objectForKey:_CPKeyedArchiverUIDKey], + processedObject = [object _cibInstantiate]; + + if (processedObject != object) + { + object = processedObject; + + [self replaceObjectAtUID:index withObject:processedObject]; + } + } + + return object; +} + +- (void)replaceObjectAtUID:(int)aUID withObject:(id)anObject +{ + _objects[aUID] = anObject; +} + +@end \ No newline at end of file diff --git a/AppKit/Cib/_CPCibWindowTemplate.j b/AppKit/Cib/_CPCibWindowTemplate.j index 7147656aa..dec6bd3c4 100644 --- a/AppKit/Cib/_CPCibWindowTemplate.j +++ b/AppKit/Cib/_CPCibWindowTemplate.j @@ -65,7 +65,7 @@ var _CPCibWindowTemplateMinSizeKey = @"_CPCibWindowTemplateMinSizeKey", [aCoder encodeObject:_windowView forKey:_CPCibWindowTemplateWindowViewKey]; } -- (id)awakeAfterUsingCoder:(CPCoder)aCoder +- (id)_cibInstantiate { var windowClass = CPClassFromString(_windowClass); diff --git a/AppKit/Platform/DOM/CPDOMDisplayServer.j b/AppKit/Platform/DOM/CPDOMDisplayServer.j index 0e34fef89..b2338c339 100644 --- a/AppKit/Platform/DOM/CPDOMDisplayServer.j +++ b/AppKit/Platform/DOM/CPDOMDisplayServer.j @@ -133,7 +133,7 @@ CPDOMDisplayServerViewsContext = {}; CPDOMDisplayServerInstructions[index++] = nil; break; - }}catch(e) { alert("here?" + instruction) } + }}catch(e) { CPLog("here?" + instruction) } } CPDOMDisplayServerInstructionCount = 0; @@ -155,7 +155,7 @@ CPDOMDisplayServerViewsContext = {}; [view displayIfNeeded]; } } - + [CPDOMDisplayRunLoop performSelector:@selector(run) target:CPDOMDisplayServer argument:nil order:0 modes:[CPDefaultRunLoopMode]]; } diff --git a/Tools/NibApp/HelloWorld.nib/info.nib b/Tools/NibApp/HelloWorld.nib/info.nib index b8f7650f5..d92bee152 100644 --- a/Tools/NibApp/HelloWorld.nib/info.nib +++ b/Tools/NibApp/HelloWorld.nib/info.nib @@ -7,7 +7,10 @@ IBOldestOS 5 IBOpenObjects - + + 1 + 10 + IBSystem Version 9F33 targetFramework diff --git a/Tools/NibApp/HelloWorld.nib/keyedobjects.nib b/Tools/NibApp/HelloWorld.nib/keyedobjects.nib index 3ad8add67f8afcdbeae4c98d4699dbea7bfd30f6..acebe2aa01ffb8ede7a87325d27929eefad4d8cf 100644 GI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