Revision: 11866
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=11866&view=rev
Author:   hofman
Date:     2007-12-11 13:20:21 -0800 (Tue, 11 Dec 2007)

Log Message:
-----------
Rename method and move some code around. Change deprecated alert functions. 

Modified Paths:
--------------
    trunk/bibdesk/BibEditor.m

Modified: trunk/bibdesk/BibEditor.m
===================================================================
--- trunk/bibdesk/BibEditor.m   2007-12-11 21:19:30 UTC (rev 11865)
+++ trunk/bibdesk/BibEditor.m   2007-12-11 21:20:21 UTC (rev 11866)
@@ -95,7 +95,8 @@
 
 @interface BibEditor (Private)
 
-- (void)setupButtons;
+- (void)setupActionButton;
+- (void)setupButtonCells;
 - (void)setupFields;
 - (void)setupMatrix;
 - (void)matrixFrameDidChange:(NSNotification *)notification;
@@ -168,26 +169,7 @@
     [bibTypeButton setEnabled:isEditable];
     [addFieldButton setEnabled:isEditable];
     
-    // Setup the default cells for the extraBibFields matrix
-       booleanButtonCell = [[NSButtonCell alloc] initTextCell:@""];
-       [booleanButtonCell setButtonType:NSSwitchButton];
-       [booleanButtonCell setTarget:self];
-       [booleanButtonCell setAction:@selector(changeFlag:)];
-    [booleanButtonCell setEnabled:isEditable];
-       
-       triStateButtonCell = [booleanButtonCell copy];
-       [triStateButtonCell setAllowsMixedState:YES];
-       
-       ratingButtonCell = [[BDSKRatingButtonCell alloc] initWithMaxRating:5];
-       [ratingButtonCell setImagePosition:NSImageLeft];
-       [ratingButtonCell setAlignment:NSLeftTextAlignment];
-       [ratingButtonCell setTarget:self];
-       [ratingButtonCell setAction:@selector(changeRating:)];
-    [ratingButtonCell setEnabled:isEditable];
-       
-       NSCell *cell = [[NSCell alloc] initTextCell:@""];
-       [extraBibFields setPrototype:cell];
-       [cell release];
+    [self setupButtonCells];
     
     // Setup the statusbar
        [statusBar retain]; // we need to retain, as we might remove it from 
the window
@@ -262,9 +244,8 @@
     // Setup the type popup
     [self setupTypePopUp];
     
-       // Setup the toolbar buttons.
-    // The popupbutton needs to be set before fixURLs is called, and 
-windowDidLoad gets sent after awakeFromNib.
-    [self setupButtons];
+       // Setup the action button
+    [self setupActionButton];
 
     [authorTableView setDoubleAction:@selector(showPersonDetailCmd:)];
     
@@ -801,17 +782,11 @@
     return [menu autorelease];
 }
 
-- (void)dummy:(id)obj{}
-
 - (BOOL)validateMenuItem:(NSMenuItem *)menuItem{
     
     SEL theAction = [menuItem action];
     
-       if (theAction == nil ||
-               theAction == @selector(dummy:)){ // Unused selector for 
disabled items. Needed to avoid the popupbutton to insert its own
-               return NO;
-       }
-       else if (theAction == @selector(generateCiteKey:)) {
+       if (theAction == @selector(generateCiteKey:)) {
                return isEditable;
        }
        else if (theAction == @selector(consolidateLinkedFiles:)) {
@@ -872,10 +847,27 @@
 #pragma mark Cite Key handling methods
 
 - (IBAction)showCiteKeyWarning:(id)sender{
-    if ([publication hasEmptyOrDefaultCiteKey])
-        NSBeginAlertSheet(NSLocalizedString(@"Cite Key Not Set", @"Message in 
alert dialog when duplicate citye key was found"),nil,nil,nil,[self 
window],nil,NULL,NULL,NULL,NSLocalizedString(@"The cite key has not been set. 
Please provide one.", @"Informative text in alert dialog"));
-    else if ([publication isValidCiteKey:[publication citeKey]] == NO)
-        NSBeginAlertSheet(NSLocalizedString(@"Duplicate Cite Key", @"Message 
in alert dialog when duplicate citye key was found"),nil,nil,nil,[self 
window],nil,NULL,NULL,NULL,NSLocalizedString(@"The cite key you entered is 
either already used in this document. Please provide a unique one.", 
@"Informative text in alert dialog"));
+    if ([publication hasEmptyOrDefaultCiteKey]) {
+        NSAlert *alert = [NSAlert 
alertWithMessageText:NSLocalizedString(@"Cite Key Not Set", @"Message in alert 
dialog when duplicate citye key was found") 
+                                         defaultButton:nil
+                                       alternateButton:nil
+                                           otherButton:nil
+                             informativeTextWithFormat:NSLocalizedString(@"The 
cite key has not been set. Please provide one.", @"Informative text in alert 
dialog")];
+        [alert beginSheetModalForWindow:[self window]
+                          modalDelegate:nil
+                         didEndSelector:NULL
+                            contextInfo:NULL];
+    } else if ([publication isValidCiteKey:[publication citeKey]] == NO) {
+        NSAlert *alert = [NSAlert 
alertWithMessageText:NSLocalizedString(@"Duplicate Cite Key", @"Message in 
alert dialog when duplicate citye key was found") 
+                                         defaultButton:nil
+                                       alternateButton:nil
+                                           otherButton:nil
+                             informativeTextWithFormat:NSLocalizedString(@"The 
cite key you entered is either already used in this document. Please provide a 
unique one.", @"Informative text in alert dialog")];
+        [alert beginSheetModalForWindow:[self window]
+                          modalDelegate:nil
+                         didEndSelector:NULL
+                            contextInfo:NULL];
+    }
 }
 
 - (void)updateCiteKeyDuplicateWarning{
@@ -2455,9 +2447,6 @@
 }
 
 - (void)windowWillClose:(NSNotification *)notification{
-    // @@ this finalizeChanges seems redundant now that it's in 
windowShouldClose:
-       [self finalizeChangesPreservingSelection:NO];
-    
     // close so it's not hanging around by itself; this works if the doc 
window closes, also
     [macroEditor close];
     
@@ -2874,18 +2863,6 @@
 
 @implementation BibEditor (Private)
 
-- (void)setupButtons {
-    
-       [actionButton setAlternateImage:[NSImage 
imageNamed:@"GroupAction_Pressed"]];
-       [actionButton setArrowImage:nil];
-       [actionButton setShowsMenuWhenIconClicked:YES];
-       [[actionButton cell] setAltersStateOfSelectedItem:NO];
-       [[actionButton cell] setAlwaysUsesFirstItemAsSelected:NO];
-       [[actionButton cell] setUsesItemFromMenu:NO];
-       [[actionButton cell] setRefreshesMenu:NO];
-       
-}    
-
 #define AddFields(newFields) \
     e = [newFields objectEnumerator]; \
     while(tmp = [e nextObject]){ \
@@ -3047,6 +3024,29 @@
        }
 }
 
+- (void)setupButtonCells {
+    // Setup the default cells for the extraBibFields matrix
+       booleanButtonCell = [[NSButtonCell alloc] initTextCell:@""];
+       [booleanButtonCell setButtonType:NSSwitchButton];
+       [booleanButtonCell setTarget:self];
+       [booleanButtonCell setAction:@selector(changeFlag:)];
+    [booleanButtonCell setEnabled:isEditable];
+       
+       triStateButtonCell = [booleanButtonCell copy];
+       [triStateButtonCell setAllowsMixedState:YES];
+       
+       ratingButtonCell = [[BDSKRatingButtonCell alloc] initWithMaxRating:5];
+       [ratingButtonCell setImagePosition:NSImageLeft];
+       [ratingButtonCell setAlignment:NSLeftTextAlignment];
+       [ratingButtonCell setTarget:self];
+       [ratingButtonCell setAction:@selector(changeRating:)];
+    [ratingButtonCell setEnabled:isEditable];
+       
+       NSCell *cell = [[NSCell alloc] initTextCell:@""];
+       [extraBibFields setPrototype:cell];
+       [cell release];
+}
+
 - (void)matrixFrameDidChange:(NSNotification *)notification {
     BDSKTypeManager *typeMan = [BDSKTypeManager sharedManager];
     int numEntries = [[typeMan booleanFieldsSet] count] + [[typeMan 
triStateFieldsSet] count] + [[typeMan ratingFieldsSet] count];
@@ -3059,6 +3059,16 @@
         [self setupMatrix];
 }
 
+- (void)setupActionButton {
+       [actionButton setAlternateImage:[NSImage 
imageNamed:@"GroupAction_Pressed"]];
+       [actionButton setArrowImage:nil];
+       [actionButton setShowsMenuWhenIconClicked:YES];
+       [[actionButton cell] setAltersStateOfSelectedItem:NO];
+       [[actionButton cell] setAlwaysUsesFirstItemAsSelected:NO];
+       [[actionButton cell] setUsesItemFromMenu:NO];
+       [[actionButton cell] setRefreshesMenu:NO];
+}    
+
 - (void)setupTypePopUp{
     [bibTypeButton removeAllItems];
     [bibTypeButton addItemsWithTitles:[[BDSKTypeManager sharedManager] 
bibTypesForFileType:[publication fileType]]];


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to