/Frameworks/AppKit/rhino.platform/CPDocumentController.j
http://github.com/jfahrenkrug/MapKit-HelloWorld · Unknown · 139 lines · 139 code · 0 blank · 0 comment · 0 complexity · eab46b926db63262ddce1c13a8234991 MD5 · raw file
- I;21;Foundation/CPObject.jI;21;Foundation/CPBundle.ji;12;CPDocument.jc;5371;
- var _1=nil;
- var _2=objj_allocateClassPair(CPObject,"CPDocumentController"),_3=_2.isa;
- class_addIvars(_2,[new objj_ivar("_documents"),new objj_ivar("_documentTypes")]);
- objj_registerClassPair(_2);
- objj_addClassForBundle(_2,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
- class_addMethods(_2,[new objj_method(sel_getUid("init"),function(_4,_5){
- with(_4){
- _4=objj_msgSendSuper({receiver:_4,super_class:objj_getClass("CPObject")},"init");
- if(_4){
- _documents=objj_msgSend(objj_msgSend(CPArray,"alloc"),"init");
- if(!_1){
- _1=_4;
- }
- _documentTypes=objj_msgSend(objj_msgSend(objj_msgSend(CPBundle,"mainBundle"),"infoDictionary"),"objectForKey:","CPBundleDocumentTypes");
- }
- return _4;
- }
- }),new objj_method(sel_getUid("documentForURL:"),function(_6,_7,_8){
- with(_6){
- var _9=0,_a=objj_msgSend(_documents,"count");
- for(;_9<_a;++_9){
- var _b=_documents[_9];
- if(objj_msgSend(objj_msgSend(_b,"fileURL"),"isEqual:",_8)){
- return _b;
- }
- }
- return nil;
- }
- }),new objj_method(sel_getUid("openUntitledDocumentOfType:display:"),function(_c,_d,_e,_f){
- with(_c){
- var _10=objj_msgSend(_c,"makeUntitledDocumentOfType:error:",_e,nil);
- if(_10){
- objj_msgSend(_c,"addDocument:",_10);
- }
- if(_f){
- objj_msgSend(_10,"makeWindowControllers");
- objj_msgSend(_10,"showWindows");
- }
- return _10;
- }
- }),new objj_method(sel_getUid("makeUntitledDocumentOfType:error:"),function(_11,_12,_13,_14){
- with(_11){
- return objj_msgSend(objj_msgSend(objj_msgSend(_11,"documentClassForType:",_13),"alloc"),"initWithType:error:",_13,_14);
- }
- }),new objj_method(sel_getUid("openDocumentWithContentsOfURL:display:error:"),function(_15,_16,_17,_18,_19){
- with(_15){
- var _1a=objj_msgSend(_15,"documentForURL:",_17);
- if(!_1a){
- var _1b=objj_msgSend(_15,"typeForContentsOfURL:error:",_17,_19);
- _1a=objj_msgSend(_15,"makeDocumentWithContentsOfURL:ofType:delegate:didReadSelector:contextInfo:",_17,_1b,_15,sel_getUid("document:didRead:contextInfo:"),objj_msgSend(CPDictionary,"dictionaryWithObject:forKey:",_18,"shouldDisplay"));
- }else{
- if(_18){
- objj_msgSend(_1a,"showWindows");
- }
- }
- return _1a;
- }
- }),new objj_method(sel_getUid("reopenDocumentForURL:withContentsOfURL:error:"),function(_1c,_1d,_1e,_1f,_20){
- with(_1c){
- return objj_msgSend(_1c,"makeDocumentForURL:withContentsOfURL:ofType:delegate:didReadSelector:contextInfo:",_1e,_1f,objj_msgSend(objj_msgSend(_documentTypes,"objectAtIndex:",0),"objectForKey:","CPBundleTypeName"),_1c,sel_getUid("document:didRead:contextInfo:"),nil);
- }
- }),new objj_method(sel_getUid("makeDocumentWithContentsOfURL:ofType:delegate:didReadSelector:contextInfo:"),function(_21,_22,_23,_24,_25,_26,_27){
- with(_21){
- return objj_msgSend(objj_msgSend(objj_msgSend(_21,"documentClassForType:",_24),"alloc"),"initWithContentsOfURL:ofType:delegate:didReadSelector:contextInfo:",_23,_24,_25,_26,_27);
- }
- }),new objj_method(sel_getUid("makeDocumentForURL:withContentsOfURL:ofType:delegate:didReadSelector:contextInfo:"),function(_28,_29,_2a,_2b,_2c,_2d,_2e,_2f){
- with(_28){
- return objj_msgSend(objj_msgSend(objj_msgSend(_28,"documentClassForType:",_2c),"alloc"),"initForURL:withContentsOfURL:ofType:delegate:didReadSelector:contextInfo:",_2a,_2b,_2c,_2d,_2e,_2f);
- }
- }),new objj_method(sel_getUid("document:didRead:contextInfo:"),function(_30,_31,_32,_33,_34){
- with(_30){
- if(!_33){
- return;
- }
- objj_msgSend(_30,"addDocument:",_32);
- objj_msgSend(_32,"makeWindowControllers");
- if(objj_msgSend(_34,"objectForKey:","shouldDisplay")){
- objj_msgSend(_32,"showWindows");
- }
- }
- }),new objj_method(sel_getUid("newDocument:"),function(_35,_36,_37){
- with(_35){
- objj_msgSend(_35,"openUntitledDocumentOfType:display:",objj_msgSend(objj_msgSend(_documentTypes,"objectAtIndex:",0),"objectForKey:","CPBundleTypeName"),YES);
- }
- }),new objj_method(sel_getUid("documents"),function(_38,_39){
- with(_38){
- return _documents;
- }
- }),new objj_method(sel_getUid("addDocument:"),function(_3a,_3b,_3c){
- with(_3a){
- objj_msgSend(_documents,"addObject:",_3c);
- }
- }),new objj_method(sel_getUid("removeDocument:"),function(_3d,_3e,_3f){
- with(_3d){
- objj_msgSend(_documents,"removeObjectIdenticalTo:",_3f);
- }
- }),new objj_method(sel_getUid("defaultType"),function(_40,_41){
- with(_40){
- return objj_msgSend(_documentTypes[0],"objectForKey:","CPBundleTypeName");
- }
- }),new objj_method(sel_getUid("typeForContentsOfURL:error:"),function(_42,_43,_44,_45){
- with(_42){
- var _46=0,_47=_documentTypes.length,_48=objj_msgSend(objj_msgSend(_44,"pathExtension"),"lowercaseString");
- for(;_46<_47;++_46){
- var _49=_documentTypes[_46],_4a=objj_msgSend(_49,"objectForKey:","CFBundleTypeExtensions"),_4b=0,_4c=_4a.length;
- for(;_4b<_4c;++_4b){
- if(objj_msgSend(_4a[_4b],"lowercaseString")==_48){
- return objj_msgSend(_49,"objectForKey:","CPBundleTypeName");
- }
- }
- }
- return objj_msgSend(_42,"defaultType");
- }
- }),new objj_method(sel_getUid("_infoForType:"),function(_4d,_4e,_4f){
- with(_4d){
- var i=0,_51=objj_msgSend(_documentTypes,"count");
- for(;i<_51;++i){
- var _52=_documentTypes[i];
- if(objj_msgSend(_52,"objectForKey:","CPBundleTypeName")==_4f){
- return _52;
- }
- }
- return nil;
- }
- }),new objj_method(sel_getUid("documentClassForType:"),function(_53,_54,_55){
- with(_53){
- var _56=objj_msgSend(objj_msgSend(_53,"_infoForType:",_55),"objectForKey:","CPDocumentClass");
- return _56?CPClassFromString(_56):nil;
- }
- })]);
- class_addMethods(_3,[new objj_method(sel_getUid("sharedDocumentController"),function(_57,_58){
- with(_57){
- if(!_1){
- objj_msgSend(objj_msgSend(_57,"alloc"),"init");
- }
- return _1;
- }
- })]);