PageRenderTime 28ms CodeModel.GetById 18ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/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
  1I;21;Foundation/CPObject.jI;21;Foundation/CPBundle.ji;12;CPDocument.jc;5371;
  2var _1=nil;
  3var _2=objj_allocateClassPair(CPObject,"CPDocumentController"),_3=_2.isa;
  4class_addIvars(_2,[new objj_ivar("_documents"),new objj_ivar("_documentTypes")]);
  5objj_registerClassPair(_2);
  6objj_addClassForBundle(_2,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  7class_addMethods(_2,[new objj_method(sel_getUid("init"),function(_4,_5){
  8with(_4){
  9_4=objj_msgSendSuper({receiver:_4,super_class:objj_getClass("CPObject")},"init");
 10if(_4){
 11_documents=objj_msgSend(objj_msgSend(CPArray,"alloc"),"init");
 12if(!_1){
 13_1=_4;
 14}
 15_documentTypes=objj_msgSend(objj_msgSend(objj_msgSend(CPBundle,"mainBundle"),"infoDictionary"),"objectForKey:","CPBundleDocumentTypes");
 16}
 17return _4;
 18}
 19}),new objj_method(sel_getUid("documentForURL:"),function(_6,_7,_8){
 20with(_6){
 21var _9=0,_a=objj_msgSend(_documents,"count");
 22for(;_9<_a;++_9){
 23var _b=_documents[_9];
 24if(objj_msgSend(objj_msgSend(_b,"fileURL"),"isEqual:",_8)){
 25return _b;
 26}
 27}
 28return nil;
 29}
 30}),new objj_method(sel_getUid("openUntitledDocumentOfType:display:"),function(_c,_d,_e,_f){
 31with(_c){
 32var _10=objj_msgSend(_c,"makeUntitledDocumentOfType:error:",_e,nil);
 33if(_10){
 34objj_msgSend(_c,"addDocument:",_10);
 35}
 36if(_f){
 37objj_msgSend(_10,"makeWindowControllers");
 38objj_msgSend(_10,"showWindows");
 39}
 40return _10;
 41}
 42}),new objj_method(sel_getUid("makeUntitledDocumentOfType:error:"),function(_11,_12,_13,_14){
 43with(_11){
 44return objj_msgSend(objj_msgSend(objj_msgSend(_11,"documentClassForType:",_13),"alloc"),"initWithType:error:",_13,_14);
 45}
 46}),new objj_method(sel_getUid("openDocumentWithContentsOfURL:display:error:"),function(_15,_16,_17,_18,_19){
 47with(_15){
 48var _1a=objj_msgSend(_15,"documentForURL:",_17);
 49if(!_1a){
 50var _1b=objj_msgSend(_15,"typeForContentsOfURL:error:",_17,_19);
 51_1a=objj_msgSend(_15,"makeDocumentWithContentsOfURL:ofType:delegate:didReadSelector:contextInfo:",_17,_1b,_15,sel_getUid("document:didRead:contextInfo:"),objj_msgSend(CPDictionary,"dictionaryWithObject:forKey:",_18,"shouldDisplay"));
 52}else{
 53if(_18){
 54objj_msgSend(_1a,"showWindows");
 55}
 56}
 57return _1a;
 58}
 59}),new objj_method(sel_getUid("reopenDocumentForURL:withContentsOfURL:error:"),function(_1c,_1d,_1e,_1f,_20){
 60with(_1c){
 61return 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);
 62}
 63}),new objj_method(sel_getUid("makeDocumentWithContentsOfURL:ofType:delegate:didReadSelector:contextInfo:"),function(_21,_22,_23,_24,_25,_26,_27){
 64with(_21){
 65return objj_msgSend(objj_msgSend(objj_msgSend(_21,"documentClassForType:",_24),"alloc"),"initWithContentsOfURL:ofType:delegate:didReadSelector:contextInfo:",_23,_24,_25,_26,_27);
 66}
 67}),new objj_method(sel_getUid("makeDocumentForURL:withContentsOfURL:ofType:delegate:didReadSelector:contextInfo:"),function(_28,_29,_2a,_2b,_2c,_2d,_2e,_2f){
 68with(_28){
 69return objj_msgSend(objj_msgSend(objj_msgSend(_28,"documentClassForType:",_2c),"alloc"),"initForURL:withContentsOfURL:ofType:delegate:didReadSelector:contextInfo:",_2a,_2b,_2c,_2d,_2e,_2f);
 70}
 71}),new objj_method(sel_getUid("document:didRead:contextInfo:"),function(_30,_31,_32,_33,_34){
 72with(_30){
 73if(!_33){
 74return;
 75}
 76objj_msgSend(_30,"addDocument:",_32);
 77objj_msgSend(_32,"makeWindowControllers");
 78if(objj_msgSend(_34,"objectForKey:","shouldDisplay")){
 79objj_msgSend(_32,"showWindows");
 80}
 81}
 82}),new objj_method(sel_getUid("newDocument:"),function(_35,_36,_37){
 83with(_35){
 84objj_msgSend(_35,"openUntitledDocumentOfType:display:",objj_msgSend(objj_msgSend(_documentTypes,"objectAtIndex:",0),"objectForKey:","CPBundleTypeName"),YES);
 85}
 86}),new objj_method(sel_getUid("documents"),function(_38,_39){
 87with(_38){
 88return _documents;
 89}
 90}),new objj_method(sel_getUid("addDocument:"),function(_3a,_3b,_3c){
 91with(_3a){
 92objj_msgSend(_documents,"addObject:",_3c);
 93}
 94}),new objj_method(sel_getUid("removeDocument:"),function(_3d,_3e,_3f){
 95with(_3d){
 96objj_msgSend(_documents,"removeObjectIdenticalTo:",_3f);
 97}
 98}),new objj_method(sel_getUid("defaultType"),function(_40,_41){
 99with(_40){
100return objj_msgSend(_documentTypes[0],"objectForKey:","CPBundleTypeName");
101}
102}),new objj_method(sel_getUid("typeForContentsOfURL:error:"),function(_42,_43,_44,_45){
103with(_42){
104var _46=0,_47=_documentTypes.length,_48=objj_msgSend(objj_msgSend(_44,"pathExtension"),"lowercaseString");
105for(;_46<_47;++_46){
106var _49=_documentTypes[_46],_4a=objj_msgSend(_49,"objectForKey:","CFBundleTypeExtensions"),_4b=0,_4c=_4a.length;
107for(;_4b<_4c;++_4b){
108if(objj_msgSend(_4a[_4b],"lowercaseString")==_48){
109return objj_msgSend(_49,"objectForKey:","CPBundleTypeName");
110}
111}
112}
113return objj_msgSend(_42,"defaultType");
114}
115}),new objj_method(sel_getUid("_infoForType:"),function(_4d,_4e,_4f){
116with(_4d){
117var i=0,_51=objj_msgSend(_documentTypes,"count");
118for(;i<_51;++i){
119var _52=_documentTypes[i];
120if(objj_msgSend(_52,"objectForKey:","CPBundleTypeName")==_4f){
121return _52;
122}
123}
124return nil;
125}
126}),new objj_method(sel_getUid("documentClassForType:"),function(_53,_54,_55){
127with(_53){
128var _56=objj_msgSend(objj_msgSend(_53,"_infoForType:",_55),"objectForKey:","CPDocumentClass");
129return _56?CPClassFromString(_56):nil;
130}
131})]);
132class_addMethods(_3,[new objj_method(sel_getUid("sharedDocumentController"),function(_57,_58){
133with(_57){
134if(!_1){
135objj_msgSend(objj_msgSend(_57,"alloc"),"init");
136}
137return _1;
138}
139})]);