Revision: 18418
http://bibdesk.svn.sourceforge.net/bibdesk/?rev=18418&view=rev
Author: hofman
Date: 2012-01-18 12:37:48 +0000 (Wed, 18 Jan 2012)
Log Message:
-----------
set document info in sheet callback
Modified Paths:
--------------
trunk/bibdesk/BDSKDocumentInfoWindowController.h
trunk/bibdesk/BDSKDocumentInfoWindowController.m
trunk/bibdesk/BibDocument_Actions.m
Modified: trunk/bibdesk/BDSKDocumentInfoWindowController.h
===================================================================
--- trunk/bibdesk/BDSKDocumentInfoWindowController.h 2012-01-18 12:15:31 UTC
(rev 18417)
+++ trunk/bibdesk/BDSKDocumentInfoWindowController.h 2012-01-18 12:37:48 UTC
(rev 18418)
@@ -38,18 +38,18 @@
#import <Cocoa/Cocoa.h>
-@class BibDocument;
@interface BDSKDocumentInfoWindowController : NSWindowController
<NSTableViewDelegate, NSTableViewDataSource> {
IBOutlet NSTableView *tableView;
IBOutlet NSSegmentedControl *addRemoveButton;
NSMutableDictionary *info;
NSMutableArray *keys;
- BibDocument *document;
BOOL ignoreEdit;
}
-- (id)initWithDocument:(BibDocument *)aDocument;
- (IBAction)addRemoveKey:(id)sender;
+- (void)setInfo:(NSDictionary *)newInfo;
+- (NSDictionary *)info;
+
@end
Modified: trunk/bibdesk/BDSKDocumentInfoWindowController.m
===================================================================
--- trunk/bibdesk/BDSKDocumentInfoWindowController.m 2012-01-18 12:15:31 UTC
(rev 18417)
+++ trunk/bibdesk/BDSKDocumentInfoWindowController.m 2012-01-18 12:37:48 UTC
(rev 18418)
@@ -37,7 +37,6 @@
*/
#import "BDSKDocumentInfoWindowController.h"
-#import "BibDocument.h"
#import "NSDictionary_BDSKExtensions.h"
#import "NSWindowController_BDSKExtensions.h"
#import "NSString_BDSKExtensions.h"
@@ -46,16 +45,9 @@
@implementation BDSKDocumentInfoWindowController
- (id)init {
- self = [self initWithDocument:nil];
- return self;
-}
-
-// designated initializer
-- (id)initWithDocument:(BibDocument *)aDocument {
self = [super initWithWindowNibName:@"DocumentInfoWindow"];
if (self) {
- document = aDocument;
- info = nil;
+ info = [[NSMutableDictionary alloc] initForCaseInsensitiveKeys];
keys = nil;
ignoreEdit = NO;
}
@@ -78,19 +70,12 @@
[keys sortUsingSelector:@selector(compare:)];
}
-- (void)resetInfo{
- if (info == nil)
- info = [[NSMutableDictionary alloc] initForCaseInsensitiveKeys];
- [info setDictionary:[document documentInfo]];
- [self refreshKeys];
-}
-
- (void)updateButtons{
[addRemoveButton setEnabled:[tableView numberOfSelectedRows] > 0
forSegment:1];
}
- (void)awakeFromNib{
- [self resetInfo];
+ [tableView reloadData];
[self updateButtons];
}
@@ -105,13 +90,13 @@
[self finalizeChangesIgnoringEdit:YES];
}
-#pragma mark Showing the window
+- (void)setInfo:(NSDictionary *)newInfo {
+ [info setDictionary:newInfo];
+ [self refreshKeys];
+}
-- (void)beginSheetModalForWindow:(NSWindow *)window modalDelegate:(id)delegate
didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo {
- [self window]; // make sure the nib is loaded
- [self resetInfo];
- [tableView reloadData];
- [super beginSheetModalForWindow:window modalDelegate:delegate
didEndSelector:didEndSelector contextInfo:contextInfo];
+- (NSDictionary *)info {
+ return info;
}
#pragma mark Button actions
@@ -119,16 +104,10 @@
- (IBAction)dismiss:(id)sender{
[self finalizeChangesIgnoringEdit:[sender tag] == NSCancelButton]; //
commit edit before reloading
- if ([sender tag] == NSOKButton) {
- if ([tableView editedRow] != -1) {
- NSBeep();
- return;
- }
- [document setDocumentInfo:info];
- [[document undoManager]
setActionName:NSLocalizedString(@"Change Document Info", @"Undo action name")];
- }
-
- [super dismiss:sender];
+ if ([sender tag] == NSOKButton && [tableView editedRow] != -1)
+ NSBeep();
+ else
+ [super dismiss:sender];
}
- (IBAction)addRemoveKey:(id)sender{
Modified: trunk/bibdesk/BibDocument_Actions.m
===================================================================
--- trunk/bibdesk/BibDocument_Actions.m 2012-01-18 12:15:31 UTC (rev 18417)
+++ trunk/bibdesk/BibDocument_Actions.m 2012-01-18 12:37:48 UTC (rev 18418)
@@ -1386,9 +1386,20 @@
return;
}
+- (void)documentInfoSheetDidEnd:(BDSKDocumentInfoWindowController
*)infoController returnCode:(NSInteger)returnCode contextInfo:(void
*)contextInfo{
+ if (returnCode == NSOKButton) {
+ NSDictionary *info = [infoController info];
+ if ([info isEqualToDictionary:[self documentInfo]] == NO) {
+ [self setDocumentInfo:info];
+ [[self undoManager] setActionName:NSLocalizedString(@"Change
Document Info", @"Undo action name")];
+ }
+ }
+}
+
- (IBAction)showDocumentInfoWindow:(id)sender{
- BDSKDocumentInfoWindowController *infoWC =
[[(BDSKDocumentInfoWindowController *)[BDSKDocumentInfoWindowController alloc]
initWithDocument:self] autorelease];
- [infoWC beginSheetModalForWindow:documentWindow];
+ BDSKDocumentInfoWindowController *infoWC =
[[[BDSKDocumentInfoWindowController alloc] init] autorelease];
+ [infoWC setInfo:[self documentInfo]];
+ [infoWC beginSheetModalForWindow:documentWindow modalDelegate:self
didEndSelector:@selector(documentInfoSheetDidEnd:returnCode:contextInfo:)
contextInfo:NULL];
}
- (IBAction)showMacrosWindow:(id)sender{
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit