/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

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