Revision: 29377
http://sourceforge.net/p/bibdesk/svn/29377
Author: hofman
Date: 2025-07-28 09:00:28 +0000 (Mon, 28 Jul 2025)
Log Message:
-----------
Reorganize code
Modified Paths:
--------------
trunk/bibdesk/BibDocument.h
trunk/bibdesk/BibDocument.m
trunk/bibdesk/BibDocument_Actions.m
Modified: trunk/bibdesk/BibDocument.h
===================================================================
--- trunk/bibdesk/BibDocument.h 2025-07-28 08:44:37 UTC (rev 29376)
+++ trunk/bibdesk/BibDocument.h 2025-07-28 09:00:28 UTC (rev 29377)
@@ -343,8 +343,6 @@
@property (nonatomic, readonly, getter=isMainDocument) BOOL mainDocument;
-- (BOOL)commitPendingEdits;
-
- (BOOL)writeArchiveToURL:(NSURL *)fileURL error:(NSError **)outError;
- (nullable NSData *)dataUsingTemplate:(BDSKTemplate *)template;
Modified: trunk/bibdesk/BibDocument.m
===================================================================
--- trunk/bibdesk/BibDocument.m 2025-07-28 08:44:37 UTC (rev 29376)
+++ trunk/bibdesk/BibDocument.m 2025-07-28 09:00:28 UTC (rev 29377)
@@ -273,6 +273,8 @@
- (void)encodeWithCoder:(NSCoder *)encoder {}
+#pragma mark Document opening
+
- (NSString *)windowNibName{
return @"BibDocument";
}
@@ -573,72 +575,10 @@
[self performSelectorOnce:@selector(doUpdatePreviews) withObject:nil
afterDelay:0.0];
}
-- (BOOL)undoManagerShouldUndoChange:(id)sender{
- if ([[self class] autosavesInPlace] == NO && ![self isDocumentEdited]) {
- NSAlert *alert = [[NSAlert alloc] init];
- [alert setMessageText:NSLocalizedString(@"Warning", @"Message in alert
dialog")];
- [alert setInformativeText:NSLocalizedString(@"You are about to undo
past the last point this file was saved. Do you want to do this?",
@"Informative text in alert dialog")];
- [alert addButtonWithTitle:NSLocalizedString(@"Yes", @"Button title")];
- [alert addButtonWithTitle:NSLocalizedString(@"No", @"Button title")];
-
- NSInteger rv = [alert runModal];
- if (rv == NSAlertSecondButtonReturn)
- return NO;
- }
- return YES;
-}
-
-// the following 3 are needed for the BDSKOwner protocol
-- (NSUndoManager *)undoManager {
- return [super undoManager];
-}
-
-- (NSURL *)fileURL {
- return [super fileURL];
-}
-
-- (void)setFileURL:(NSURL *)absoluteURL{
- [super setFileURL:absoluteURL];
- [self setBasePath:[[[absoluteURL URLByStandardizingPath]
URLByDeletingLastPathComponent] path]];
- [self updateFileViews];
- [self updatePreviews];
- [[NSNotificationCenter defaultCenter]
postNotificationName:BDSKDocumentFileURLDidChangeNotification object:self];
-}
-
-- (void)setBasePath:(NSString *)newBasePath {
- if ([newBasePath isEqualToString:basePath] == NO) {
- basePath = newBasePath;
- if (basePath)
- [publications
makeObjectsPerformSelector:@selector(basePathDidChange)];
- }
-}
-
-- (BOOL)isDocument{
- return YES;
-}
-
- (BOOL)isMainDocument {
return [[[NSDocumentController sharedDocumentController] mainDocument]
isEqual:self];
}
-- (NSWindow *)windowForSheetForObject:(id)object {
- if ([object isKindOfClass:[BibItem class]]) {
- BDSKEditor *editor = [self editorForPublication:object create:NO];
- if (editor)
- return [editor window];
- }
- return [self windowForSheet];
-}
-
-- (BOOL)commitPendingEdits {
- for (id editor in [self windowControllers]) {
- // not all window controllers are editors...
- if ([editor respondsToSelector:@selector(commitEditing)] && [editor
commitEditing] == NO)
- return NO;
- }
- return YES;
-}
-
#pragma mark Document closing
- (void)document:(NSDocument *)doc shouldClose:(BOOL)shouldClose
contextInfo:(void *)contextInfo {
@@ -898,6 +838,61 @@
}
#pragma mark -
+#pragma mark BDSKOwner protocol
+
+- (BOOL)undoManagerShouldUndoChange:(id)sender{
+ if ([[self class] autosavesInPlace] == NO && ![self isDocumentEdited]) {
+ NSAlert *alert = [[NSAlert alloc] init];
+ [alert setMessageText:NSLocalizedString(@"Warning", @"Message in alert
dialog")];
+ [alert setInformativeText:NSLocalizedString(@"You are about to undo
past the last point this file was saved. Do you want to do this?",
@"Informative text in alert dialog")];
+ [alert addButtonWithTitle:NSLocalizedString(@"Yes", @"Button title")];
+ [alert addButtonWithTitle:NSLocalizedString(@"No", @"Button title")];
+
+ NSInteger rv = [alert runModal];
+ if (rv == NSAlertSecondButtonReturn)
+ return NO;
+ }
+ return YES;
+}
+
+// the following 3 are needed for the BDSKOwner protocol
+- (NSUndoManager *)undoManager {
+ return [super undoManager];
+}
+
+- (NSURL *)fileURL {
+ return [super fileURL];
+}
+
+- (void)setFileURL:(NSURL *)absoluteURL{
+ [super setFileURL:absoluteURL];
+ [self setBasePath:[[[absoluteURL URLByStandardizingPath]
URLByDeletingLastPathComponent] path]];
+ [self updateFileViews];
+ [self updatePreviews];
+ [[NSNotificationCenter defaultCenter]
postNotificationName:BDSKDocumentFileURLDidChangeNotification object:self];
+}
+
+- (void)setBasePath:(NSString *)newBasePath {
+ if ([newBasePath isEqualToString:basePath] == NO) {
+ basePath = newBasePath;
+ if (basePath)
+ [publications
makeObjectsPerformSelector:@selector(basePathDidChange)];
+ }
+}
+
+- (BOOL)isDocument{
+ return YES;
+}
+
+- (NSWindow *)windowForSheetForObject:(id)object {
+ if ([object isKindOfClass:[BibItem class]]) {
+ BDSKEditor *editor = [self editorForPublication:object create:NO];
+ if (editor)
+ return [editor window];
+ }
+ return [self windowForSheet];
+}
+
#pragma mark Publications acessors
// This is not undoable!
Modified: trunk/bibdesk/BibDocument_Actions.m
===================================================================
--- trunk/bibdesk/BibDocument_Actions.m 2025-07-28 08:44:37 UTC (rev 29376)
+++ trunk/bibdesk/BibDocument_Actions.m 2025-07-28 09:00:28 UTC (rev 29377)
@@ -1426,8 +1426,19 @@
}];
}
-#pragma mark AutoFile stuff
+#pragma mark Commit edits
+- (BOOL)commitPendingEdits {
+ for (id editor in [self windowControllers]) {
+ // not all window controllers are editors...
+ if ([editor respondsToSelector:@selector(commitEditing)] && [editor
commitEditing] == NO)
+ return NO;
+ }
+ return YES;
+}
+
+#pragma mark AutoFile
+
- (IBAction)consolidateLinkedFiles:(id)sender{
if ([self displaysFileSearch] == NSMixedState || [self
hasGroupTypeSelected:BDSKExternalGroupType]) {
NSBeep();
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit