API  0.9.10
CPDocument.j
Go to the documentation of this file.
1 /*
2  * CPDocument.j
3  * AppKit
4  *
5  * Created by Francisco Tolmasky.
6  * Copyright 2008, 280 North, Inc.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 
24 
25 
26 @global CPApp
27 
28 
29 /*
30  @global
31  @group CPSaveOperationType
32 */
34 /*
35  @global
36  @group CPSaveOperationType
37 */
39 /*
40  @global
41  @group CPSaveOperationType
42 */
44 /*
45  @global
46  @group CPSaveOperationType
47 */
49 
50 /*
51  @global
52  @group CPDocumentChangeType
53 */
55 /*
56  @global
57  @group CPDocumentChangeType
58 */
60 /*
61  @global
62  @group CPDocumentChangeType
63 */
65 /*
66  @global
67  @group CPDocumentChangeType
68 */
70 /*
71  @global
72  @group CPDocumentChangeType
73 */
75 
76 CPDocumentWillSaveNotification = @"CPDocumentWillSaveNotification";
77 CPDocumentDidSaveNotification = @"CPDocumentDidSaveNotification";
78 CPDocumentDidFailToSaveNotification = @"CPDocumentDidFailToSaveNotification";
79 
81 
90 @implementation CPDocument : CPResponder
91 {
92  CPWindow _window; // For outlet purposes.
93  CPView _view; // For outlet purposes
94  CPDictionary _viewControllersForWindowControllers;
95 
96  CPURL _fileURL;
97  CPString _fileType;
98  CPArray _windowControllers;
99  unsigned _untitledDocumentIndex;
100 
101  BOOL _hasUndoManager;
102  CPUndoManager _undoManager;
103 
104  int _changeCount;
105 
106  CPURLConnection _readConnection;
107  CPURLRequest _writeRequest;
108 
109  CPAlert _canCloseAlert;
110 }
111 
116 - (id)init
117 {
118  self = [super init];
119 
120  if (self)
121  {
122  _windowControllers = [];
123  _viewControllersForWindowControllers = @{};
124 
125  _hasUndoManager = YES;
126  _changeCount = 0;
127 
128  [self setNextResponder:CPApp];
129  }
130 
131  return self;
132 }
133 
140 - (id)initWithType:(CPString)aType error:(/*{*/CPError/*}*/)anError
141 {
142  self = [self init];
143 
144  if (self)
145  [self setFileType:aType];
146 
147  return self;
148 }
149 
161 - (id)initWithContentsOfURL:(CPURL)anAbsoluteURL ofType:(CPString)aType delegate:(id)aDelegate didReadSelector:(SEL)aDidReadSelector contextInfo:(id)aContextInfo
162 {
163  self = [self init];
164 
165  if (self)
166  {
167  [self setFileURL:anAbsoluteURL];
168  [self setFileType:aType];
169 
170  [self readFromURL:anAbsoluteURL ofType:aType delegate:aDelegate didReadSelector:aDidReadSelector contextInfo:aContextInfo];
171  }
172 
173  return self;
174 }
175 
186 - (id)initForURL:(CPURL)anAbsoluteURL withContentsOfURL:(CPURL)absoluteContentsURL ofType:(CPString)aType delegate:(id)aDelegate didReadSelector:(SEL)aDidReadSelector contextInfo:(id)aContextInfo
187 {
188  self = [self init];
189 
190  if (self)
191  {
192  [self setFileURL:anAbsoluteURL];
193  [self setFileType:aType];
194 
195  [self readFromURL:absoluteContentsURL ofType:aType delegate:aDelegate didReadSelector:aDidReadSelector contextInfo:aContextInfo];
196  }
197 
198  return self;
199 }
200 
209 - (CPData)dataOfType:(CPString)aType error:(/*{*/CPError/*}*/)anError
210 {
211  [CPException raise:CPUnsupportedMethodException
212  reason:"dataOfType:error: must be overridden by the document subclass."];
213 }
214 
224 - (void)readFromData:(CPData)aData ofType:(CPString)aType error:(CPError)anError
225 {
226  [CPException raise:CPUnsupportedMethodException
227  reason:"readFromData:ofType: must be overridden by the document subclass."];
228 }
229 
230 - (void)viewControllerWillLoadCib:(CPViewController)aViewController
231 {
232 }
233 
234 - (void)viewControllerDidLoadCib:(CPViewController)aViewController
235 {
236 }
237 
238 // Creating and managing window controllers
243 {
245 }
246 
248 {
249  var viewCibName = [self viewCibName],
250  windowCibName = [self windowCibName],
251  viewController = nil,
252  windowController = nil;
253 
254  // Create our view controller if we have a cib for it.
255  if ([viewCibName length])
256  viewController = [[CPViewController alloc] initWithCibName:viewCibName bundle:nil owner:self];
257 
258  // From a cib if we have one.
259  if ([windowCibName length])
260  windowController = [[CPWindowController alloc] initWithWindowCibName:windowCibName owner:self];
261 
262  // If not you get a standard window capable of displaying multiple documents and view
263  else if (viewController)
264  {
265  var view = [viewController view],
266  viewFrame = [view frame];
267 
268  viewFrame.origin = CGPointMake(50, 50);
269 
270  var theWindow = [[CPWindow alloc] initWithContentRect:viewFrame styleMask:CPTitledWindowMask | CPClosableWindowMask | CPMiniaturizableWindowMask | CPResizableWindowMask];
271 
272  windowController = [[CPWindowController alloc] initWithWindow:theWindow];
273  }
274 
275  if (windowController && viewController)
276  [windowController setSupportsMultipleDocuments:YES];
277 
278  if (windowController)
279  [self addWindowController:windowController];
280 
281  if (viewController)
282  [self addViewController:viewController forWindowController:windowController];
283 }
284 
289 {
290  return _windowControllers;
291 }
292 
298 - (void)addWindowController:(CPWindowController)aWindowController
299 {
300  [_windowControllers addObject:aWindowController];
301 
302  if ([aWindowController document] !== self)
303  [aWindowController setDocument:self];
304 }
305 
311 - (void)removeWindowController:(CPWindowController)aWindowController
312 {
313  if (aWindowController)
314  [_windowControllers removeObject:aWindowController];
315 
316  if ([aWindowController document] === self)
317  [aWindowController setDocument:nil];
318 }
319 
321 {
322  return _view;
323 }
324 
325 - (CPArray)viewControllers
326 {
327  return [_viewControllersForWindowControllers allValues];
328 }
329 
330 - (void)addViewController:(CPViewController)aViewController forWindowController:(CPWindowController)aWindowController
331 {
332  // FIXME: exception if we don't own the window controller?
333  [_viewControllersForWindowControllers setObject:aViewController forKey:[aWindowController UID]];
334 
335  if ([aWindowController document] === self)
336  [aWindowController setViewController:aViewController];
337 }
338 
339 - (void)removeViewController:(CPViewController)aViewController
340 {
341  [_viewControllersForWindowControllers removeObject:aViewController];
342 }
343 
344 - (CPViewController)viewControllerForWindowController:(CPWindowController)aWindowController
345 {
346  return [_viewControllersForWindowControllers objectForKey:[aWindowController UID]];
347 }
348 
349 // Managing Document Windows
353 - (void)showWindows
354 {
355  [_windowControllers makeObjectsPerformSelector:@selector(setDocument:) withObject:self];
356  [_windowControllers makeObjectsPerformSelector:@selector(showWindow:) withObject:self];
357 }
358 
363 {
364  if (_fileURL)
365  return [_fileURL lastPathComponent];
366 
367  if (!_untitledDocumentIndex)
368  _untitledDocumentIndex = ++CPDocumentUntitledCount;
369 
370  if (_untitledDocumentIndex == 1)
371  return @"Untitled";
372 
373  return @"Untitled " + _untitledDocumentIndex;
374 }
375 
377 {
378  return nil;
379 }
380 
385 {
386  return nil;
387 }
388 
393 - (void)windowControllerDidLoadCib:(CPWindowController)aWindowController
394 {
395 }
396 
401 - (void)windowControllerWillLoadCib:(CPWindowController)aWindowController
402 {
403 }
404 
405 // Reading from and Writing to URLs
414 - (void)readFromURL:(CPURL)anAbsoluteURL ofType:(CPString)aType delegate:(id)aDelegate didReadSelector:(SEL)aDidReadSelector contextInfo:(id)aContextInfo
415 {
416  [_readConnection cancel];
417 
418  // FIXME: Oh man is this every looking for trouble, we need to handle login at the Cappuccino level, with HTTP Errors.
419  _readConnection = [CPURLConnection connectionWithRequest:[CPURLRequest requestWithURL:anAbsoluteURL] delegate:self];
420 
421  _readConnection.session = _CPReadSessionMake(aType, aDelegate, aDidReadSelector, aContextInfo);
422 }
423 
428 {
429  return _fileURL;
430 }
431 
436 - (void)setFileURL:(CPURL)aFileURL
437 {
438  if (_fileURL === aFileURL)
439  return;
440 
441  _fileURL = aFileURL;
442 
443  [_windowControllers makeObjectsPerformSelector:@selector(synchronizeWindowTitleWithDocumentName)];
444 }
445 
456 - (void)saveToURL:(CPURL)anAbsoluteURL ofType:(CPString)aTypeName forSaveOperation:(CPSaveOperationType)aSaveOperation delegate:(id)aDelegate didSaveSelector:(SEL)aDidSaveSelector contextInfo:(id)aContextInfo
457 {
458  var data = [self dataOfType:[self fileType] error:nil],
459  oldChangeCount = _changeCount;
460 
461  _writeRequest = [CPURLRequest requestWithURL:anAbsoluteURL];
462 
463  // FIXME: THIS IS WRONG! We need a way to decide
464  if ([CPPlatform isBrowser])
465  [_writeRequest setHTTPMethod:@"POST"];
466  else
467  [_writeRequest setHTTPMethod:@"PUT"];
468 
469  [_writeRequest setHTTPBody:[data rawString]];
470 
471  [_writeRequest setValue:@"close" forHTTPHeaderField:@"Connection"];
472 
473  if (aSaveOperation === CPSaveOperation)
474  [_writeRequest setValue:@"true" forHTTPHeaderField:@"x-cappuccino-overwrite"];
475 
476  if (aSaveOperation !== CPSaveToOperation)
477  [self updateChangeCount:CPChangeCleared];
478 
479  // FIXME: Oh man is this every looking for trouble, we need to handle login at the Cappuccino level, with HTTP Errors.
480  var connection = [CPURLConnection connectionWithRequest:_writeRequest delegate:self];
481 
482  connection.session = _CPSaveSessionMake(anAbsoluteURL, aSaveOperation, oldChangeCount, aDelegate, aDidSaveSelector, aContextInfo, connection);
483 }
484 
485 /*
486  Implemented as a delegate method for CPURLConnection
487  @ignore
488 */
489 - (void)connection:(CPURLConnection)aConnection didReceiveResponse:(CPURLResponse)aResponse
490 {
491  // If we got this far and it wasn't an HTTP request, then everything is fine.
492  if (![aResponse isKindOfClass:[CPHTTPURLResponse class]])
493  return;
494 
495  var statusCode = [aResponse statusCode];
496 
497  // Nothing to do if everything is hunky dory.
498  if (statusCode === 200)
499  return;
500 
501  var session = aConnection.session;
502 
503  if (aConnection == _readConnection)
504  {
505  [aConnection cancel];
506 
507  alert("There was an error retrieving the document.");
508 
509  var theDelegate = session.delegate;
510 
511  theDelegate.isa.objj_msgSend3(theDelegate, session.didReadSelector, self, NO, session.contextInfo);
512  }
513  else
514  {
515  // 409: Conflict, in Cappuccino, overwrite protection for documents.
516  if (statusCode == 409)
517  {
518  [aConnection cancel];
519 
520  if (confirm("There already exists a file with that name, would you like to overwrite it?"))
521  {
522  [_writeRequest setValue:@"true" forHTTPHeaderField:@"x-cappuccino-overwrite"];
523 
524  [aConnection start];
525  }
526  else
527  {
528  if (session.saveOperation != CPSaveToOperation)
529  {
530  _changeCount += session.changeCount;
531  [_windowControllers makeObjectsPerformSelector:@selector(setDocumentEdited:) withObject:[self isDocumentEdited]];
532  }
533 
534  _writeRequest = nil;
535 
536  var theDelegate = session.delegate;
537 
538  theDelegate.isa.objj_msgSend3(theDelegate, session.didSaveSelector, self, NO, session.contextInfo);
539  [self _sendDocumentSavedNotification:NO];
540  }
541  }
542  }
543 }
544 
545 /*
546  Implemented as a delegate method for CPURLConnection
547  @ignore
548 */
549 - (void)connection:(CPURLConnection)aConnection didReceiveData:(CPString)aData
550 {
551  var session = aConnection.session,
552  theDelegate = session.delegate;
553 
554  // READ
555  if (aConnection == _readConnection)
556  {
557  [self readFromData:[CPData dataWithRawString:aData] ofType:session.fileType error:nil];
558 
559  theDelegate.isa.objj_msgSend3(theDelegate, session.didReadSelector, self, YES, session.contextInfo);
560  }
561  else
562  {
563  if (session.saveOperation != CPSaveToOperation)
564  [self setFileURL:session.absoluteURL];
565 
566  _writeRequest = nil;
567 
568  theDelegate.isa.objj_msgSend3(theDelegate, session.didSaveSelector, self, YES, session.contextInfo);
569  [self _sendDocumentSavedNotification:YES];
570  }
571 }
572 
573 /*
574  Implemented as a delegate method for CPURLConnection
575  @ignore
576 */
577 - (void)connection:(CPURLConnection)aConnection didFailWithError:(CPError)anError
578 {
579  var session = aConnection.session,
580  theDelegate = session.delegate;
581 
582  if (_readConnection == aConnection)
583  theDelegate.isa.objj_msgSend3(theDelegate, session.didReadSelector, self, NO, session.contextInfo);
584 
585  else
586  {
587  if (session.saveOperation != CPSaveToOperation)
588  {
589  _changeCount += session.changeCount;
590  [_windowControllers makeObjectsPerformSelector:@selector(setDocumentEdited:) withObject:[self isDocumentEdited]];
591  }
592 
593  _writeRequest = nil;
594 
595  alert("There was an error saving the document.");
596 
597  theDelegate.isa.objj_msgSend3(theDelegate, session.didSaveSelector, self, NO, session.contextInfo);
598  [self _sendDocumentSavedNotification:NO];
599  }
600 }
601 
602 /*
603  Implemented as a delegate method for CPURLConnection
604  @ignore
605 */
606 - (void)connectionDidFinishLoading:(CPURLConnection)aConnection
607 {
608  if (_readConnection == aConnection)
609  _readConnection = nil;
610 }
611 
612 // Managing Document Status
617 {
618  return _changeCount != 0;
619 }
620 
625 - (void)updateChangeCount:(CPDocumentChangeType)aChangeType
626 {
627  if (aChangeType == CPChangeDone)
628  ++_changeCount;
629  else if (aChangeType == CPChangeUndone)
630  --_changeCount;
631  else if (aChangeType == CPChangeCleared)
632  _changeCount = 0;
633  /*else if (aChangeType == CPCHangeReadOtherContents)
634 
635  else if (aChangeType == CPChangeAutosaved)*/
636 
637  [_windowControllers makeObjectsPerformSelector:@selector(setDocumentEdited:) withObject:[self isDocumentEdited]];
638 }
639 
640 // Managing File Types
645 - (void)setFileType:(CPString)aType
646 {
647  _fileType = aType;
648 }
649 
654 {
655  return _fileType;
656 }
657 
658 // Working with Undo Manager
664 {
665  return _hasUndoManager;
666 }
667 
672 - (void)setHasUndoManager:(BOOL)aFlag
673 {
674  if (_hasUndoManager == aFlag)
675  return;
676 
677  _hasUndoManager = aFlag;
678 
679  if (!_hasUndoManager)
680  [self setUndoManager:nil];
681 }
682 
683 /* @ignore */
684 - (void)_undoManagerWillCloseGroup:(CPNotification)aNotification
685 {
686  var undoManager = [aNotification object];
687 
688  if ([undoManager isUndoing] || [undoManager isRedoing])
689  return;
690 
691  [self updateChangeCount:CPChangeDone];
692 }
693 
694 /* @ignore */
695 - (void)_undoManagerDidUndoChange:(CPNotification)aNotification
696 {
697  [self updateChangeCount:CPChangeUndone];
698 }
699 
700 /* @ignore */
701 - (void)_undoManagerDidRedoChange:(CPNotification)aNotification
702 {
703  [self updateChangeCount:CPChangeDone];
704 }
705 
706 /*
707  Sets the document's undo manager. This method will add the
708  undo manager as an observer to the notification center.
709  @param anUndoManager the new undo manager for the document
710 */
711 - (void)setUndoManager:(CPUndoManager)anUndoManager
712 {
713  var defaultCenter = [CPNotificationCenter defaultCenter];
714 
715  if (_undoManager)
716  {
717  [defaultCenter removeObserver:self
718  name:CPUndoManagerDidUndoChangeNotification
719  object:_undoManager];
720 
721  [defaultCenter removeObserver:self
722  name:CPUndoManagerDidRedoChangeNotification
723  object:_undoManager];
724 
725  [defaultCenter removeObserver:self
726  name:CPUndoManagerWillCloseUndoGroupNotification
727  object:_undoManager];
728  }
729 
730  _undoManager = anUndoManager;
731 
732  if (_undoManager)
733  {
734 
735  [defaultCenter addObserver:self
736  selector:@selector(_undoManagerDidUndoChange:)
737  name:CPUndoManagerDidUndoChangeNotification
738  object:_undoManager];
739 
740  [defaultCenter addObserver:self
741  selector:@selector(_undoManagerDidRedoChange:)
742  name:CPUndoManagerDidRedoChangeNotification
743  object:_undoManager];
744 
745  [defaultCenter addObserver:self
746  selector:@selector(_undoManagerWillCloseGroup:)
747  name:CPUndoManagerWillCloseUndoGroupNotification
748  object:_undoManager];
749  }
750 }
751 
759 {
760  if (_hasUndoManager && !_undoManager)
761  [self setUndoManager:[[CPUndoManager alloc] init]];
762 
763  return _undoManager;
764 }
765 
766 /*
767  Implemented as a delegate of a CPWindow
768  @ignore
769 */
770 - (CPUndoManager)windowWillReturnUndoManager:(CPWindow)aWindow
771 {
772  return [self undoManager];
773 }
774 
775 // Handling User Actions
782 - (void)saveDocument:(id)aSender
783 {
785 }
786 
787 - (void)saveDocumentWithDelegate:(id)delegate didSaveSelector:(SEL)didSaveSelector contextInfo:(Object)contextInfo
788 {
789  if (_fileURL)
790  {
792  postNotificationName:CPDocumentWillSaveNotification
793  object:self];
794 
795  [self saveToURL:_fileURL ofType:[self fileType] forSaveOperation:CPSaveOperation delegate:delegate didSaveSelector:didSaveSelector contextInfo:contextInfo];
796  }
797  else
798  [self _saveDocumentAsWithDelegate:delegate didSaveSelector:didSaveSelector contextInfo:contextInfo];
799 }
800 
805 - (void)saveDocumentAs:(id)aSender
806 {
807  [self _saveDocumentAsWithDelegate:nil didSaveSelector:nil contextInfo:nil];
808 }
809 
810 - (void)_saveDocumentAsWithDelegate:(id)delegate didSaveSelector:(SEL)didSaveSelector contextInfo:(Object)contextInfo
811 {
812  var savePanel = [CPSavePanel savePanel],
813  response = [savePanel runModal];
814 
815  if (!response)
816  return;
817 
818  var saveURL = [savePanel URL];
819 
821  postNotificationName:CPDocumentWillSaveNotification
822  object:self];
823 
824  [self saveToURL:saveURL ofType:[self fileType] forSaveOperation:CPSaveAsOperation delegate:delegate didSaveSelector:didSaveSelector contextInfo:contextInfo];
825 }
826 
827 /*
828  @ignore
829 */
830 - (void)_sendDocumentSavedNotification:(BOOL)didSave
831 {
832  if (didSave)
834  postNotificationName:CPDocumentDidSaveNotification
835  object:self];
836  else
838  postNotificationName:CPDocumentDidFailToSaveNotification
839  object:self];
840 }
841 
842 @end
843 
845 
846 - (void)close
847 {
848  [_windowControllers makeObjectsPerformSelector:@selector(removeDocumentAndCloseIfNecessary:) withObject:self];
849  [[CPDocumentController sharedDocumentController] removeDocument:self];
850 }
851 
852 - (void)shouldCloseWindowController:(CPWindowController)controller delegate:(id)delegate shouldCloseSelector:(SEL)selector contextInfo:(Object)info
853 {
854  if ([controller shouldCloseDocument] || ([_windowControllers count] < 2 && [_windowControllers indexOfObject:controller] !== CPNotFound))
855  [self canCloseDocumentWithDelegate:self shouldCloseSelector:@selector(_document:shouldClose:context:) contextInfo:{delegate:delegate, selector:selector, context:info}];
856 
857  else if ([delegate respondsToSelector:selector])
858  delegate.isa.objj_msgSend3(delegate, selector, self, YES, info);
859 }
860 
861 - (void)_document:(CPDocument)aDocument shouldClose:(BOOL)shouldClose context:(Object)context
862 {
863  var theDelegate = context.delegate;
864 
865  if (aDocument === self && shouldClose)
866  [self close];
867 
868  if (theDelegate != null)
869  theDelegate.isa.objj_msgSend3(theDelegate, context.selector, aDocument, shouldClose, context.context);
870 }
871 
872 - (void)canCloseDocumentWithDelegate:(id)aDelegate shouldCloseSelector:(SEL)aSelector contextInfo:(Object)context
873 {
874  if (![self isDocumentEdited])
875  return [aDelegate respondsToSelector:aSelector] && aDelegate.isa.objj_msgSend3(aDelegate, aSelector, self, YES, context);
876 
877  _canCloseAlert = [[CPAlert alloc] init];
878 
879  [_canCloseAlert setDelegate:self];
880  [_canCloseAlert setAlertStyle:CPWarningAlertStyle];
881  [_canCloseAlert setTitle:@"Unsaved Document"];
882  [_canCloseAlert setMessageText:@"Do you want to save the changes you've made to the document \"" + ([self displayName] || [self fileName]) + "\"?"];
883 
884  [_canCloseAlert addButtonWithTitle:@"Save"];
885  [_canCloseAlert addButtonWithTitle:@"Cancel"];
886  [_canCloseAlert addButtonWithTitle:@"Don't Save"];
887 
888  _canCloseAlert._context = {delegate:aDelegate, selector:aSelector, context:context};
889 
890  [_canCloseAlert runModal];
891 }
892 
893 - (void)alertDidEnd:(CPAlert)alert returnCode:(int)returnCode
894 {
895  if (alert !== _canCloseAlert)
896  return;
897 
898  var delegate = alert._context.delegate,
899  selector = alert._context.selector,
900  context = alert._context.context;
901 
902  if (returnCode === 0)
903  [self saveDocumentWithDelegate:delegate didSaveSelector:selector contextInfo:context];
904  else if (delegate != null)
905  delegate.isa.objj_msgSend3(delegate, selector, self, returnCode === 2, context);
906 
907  _canCloseAlert = nil;
908 }
909 
910 @end
911 
912 var _CPReadSessionMake = function(aType, aDelegate, aDidReadSelector, aContextInfo)
913 {
914  return { fileType:aType, delegate:aDelegate, didReadSelector:aDidReadSelector, contextInfo:aContextInfo };
915 };
916 
917 var _CPSaveSessionMake = function(anAbsoluteURL, aSaveOperation, aChangeCount, aDelegate, aDidSaveSelector, aContextInfo, aConnection)
918 {
919  return { absoluteURL:anAbsoluteURL, saveOperation:aSaveOperation, changeCount:aChangeCount, delegate:aDelegate, didSaveSelector:aDidSaveSelector, contextInfo:aContextInfo, connection:aConnection };
920 };
Used to implement exception handling (creating & raising).
Definition: CPException.h:2
var CPDocumentUntitledCount
Definition: CPDocument.j:80
CPChangeDone
Definition: CPDocument.j:54
CPView view()
Definition: CPDocument.j:320
void updateChangeCount:(CPDocumentChangeType aChangeType)
Definition: CPDocument.j:625
CPArray windowControllers()
Definition: CPDocument.j:288
void setFileType:(CPString aType)
Definition: CPDocument.j:645
CPChangeCleared
Definition: CPDocument.j:64
void setUndoManager:(CPUndoManager anUndoManager)
Definition: CPDocument.j:711
id initWithCibName:bundle:owner:(CPString aCibNameOrNil, [bundle] CPBundle aCibBundleOrNil, [owner] id anOwner)
void saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo:(CPURL anAbsoluteURL, [ofType] CPString aTypeName, [forSaveOperation] CPSaveOperationType aSaveOperation, [delegate] id aDelegate, [didSaveSelector] SEL aDidSaveSelector, [contextInfo] id aContextInfo)
Definition: CPDocument.j:456
void setDocument:(CPDocument aDocument)
id delegate()
Definition: CALayer.j:965
A Cappuccino wrapper for any data type.
Definition: CPData.h:2
void postNotificationName:object:(CPString aNotificationName, [object] id anObject)
void raise:reason:(CPString aName, [reason] CPString aReason)
Definition: CPException.j:66
Provides loading of a URL request.
void makeWindowControllers()
Definition: CPDocument.j:242
CPString viewCibName()
Definition: CPDocument.j:376
CPNotificationCenter defaultCenter()
A mutable key-value pair collection.
Definition: CPDictionary.h:2
void addWindowController:(CPWindowController aWindowController)
Definition: CPDocument.j:298
void makeViewAndWindowControllers()
Definition: CPDocument.j:247
void addViewController:forWindowController:(CPViewController aViewController, [forWindowController] CPWindowController aWindowController)
Definition: CPDocument.j:330
id requestWithURL:(CPURL aURL)
Definition: CPURLRequest.j:56
CPSaveAsOperation
Definition: CPDocument.j:38
id initWithContentRect:styleMask:(CGRect aContentRect, [styleMask] unsigned aStyleMask)
Definition: CPWindow.j:263
void setViewController:(CPViewController aViewController)
An immutable string (collection of characters).
Definition: CPString.h:2
CPAutosaveOperation
Definition: CPDocument.j:48
BOOL hasUndoManager()
Definition: CPDocument.j:663
id initWithWindowCibName:owner:(CPString aWindowCibName, [owner] id anOwner)
CPChangeUndone
Definition: CPDocument.j:59
CPDocumentDidFailToSaveNotification
Definition: CPDocument.j:78
Protocol agnostic information about a request to a specific URL.
Definition: CPURLResponse.h:2
void close()
Definition: CPDocument.j:846
CPDocumentDidSaveNotification
Definition: CPDocument.j:77
global CPApp CPSaveOperation
Definition: CPDocument.j:33
CPData dataWithRawString:(CPString aString)
Definition: CPData.j:45
CPData dataOfType:error:(CPString aType, [error]/*{ */CPError/*} */anError)
Definition: CPDocument.j:209
A notification that can be posted to a CPNotificationCenter.
Definition: CPNotification.h:2
void setFileURL:(CPURL aFileURL)
Definition: CPDocument.j:436
CPChangeAutosaved
Definition: CPDocument.j:74
BOOL isDocumentEdited()
Definition: CPDocument.j:616
Used for encapsulating, presenting, and recovery from errors.
Definition: CPError.h:2
CPChangeReadOtherContents
Definition: CPDocument.j:69
A general mechanism for user action "undo".
Definition: CPUndoManager.h:2
CPURLConnection connectionWithRequest:delegate:(CPURLRequest aRequest, [delegate] id aDelegate)
CPNotFound
Definition: CPObjJRuntime.j:62
id init()
Definition: CPObject.j:145
CPURL fileURL()
Definition: CPDocument.j:427
Sends messages (CPNotification) between objects.
Definition: CPAlert.h:2
CPDocumentWillSaveNotification
Definition: CPDocument.j:76
CPString fileType()
Definition: CPDocument.j:653
void setNextResponder:(CPResponder aResponder)
Definition: CPResponder.j:83
void saveDocumentWithDelegate:didSaveSelector:contextInfo:(id delegate, [didSaveSelector] SEL didSaveSelector, [contextInfo] Object contextInfo)
Definition: CPDocument.j:787
CPArray viewControllers()
Definition: CPDocument.j:325
Contains data obtained during a request made with CPURLConnection.
Definition: CPURLRequest.h:2
void readFromURL:ofType:delegate:didReadSelector:contextInfo:(CPURL anAbsoluteURL, [ofType] CPString aType, [delegate] id aDelegate, [didReadSelector] SEL aDidReadSelector, [contextInfo] id aContextInfo)
Definition: CPDocument.j:414
CPString windowCibName()
Definition: CPDocument.j:384
void readFromData:ofType:error:(CPData aData, [ofType] CPString aType, [error] CPError anError)
Definition: CPDocument.j:224
CPString displayName()
Definition: CPDocument.j:362
Definition: CPURL.h:2
void showWindows()
Definition: CPDocument.j:353
CPString UID()
Definition: CPObject.j:552
id alloc()
Definition: CPObject.j:130
CPSaveToOperation
Definition: CPDocument.j:43
Definition: CPView.j:136
CPUndoManager undoManager()
Definition: CPDocument.j:758