From 5067b75ff7d4219f960fa9fe146c5fcb98d8f766 Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Sat, 26 Jun 2004 22:08:42 +0000 Subject: [PATCH] Some bugfixes and enhancements. Correction for Report #9461. Adds ability of Class Inspector to change the name of a class. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@19626 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 15 +++++++++++++++ GormClassInspector.m | 22 ++++++++++++++++------ GormDocument.m | 11 ++++++++--- GormInspectorsManager.m | 41 ++++++++++++++++++++++++++--------------- 4 files changed, 65 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5c7615e7..89a32d4d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2004-06-26 18:10 Gregory John Casamento + + * GormPalettesManager.m: Removed line in -init which observes + IBDidDeleteConnectionNotification in GormConnectionInspector. + It was causing a number of bugs since it could potentially modify + the connection prior to adding it to the connections list. Added + method _selectAction: which is used to select the action without + going through all of the other code in _internalCall:. + * GormDocument.m: Added code in NSNibConnector category to let + isEqual immediately return true if the object and self are precisely + the same object. + * GormClassInspector.m: Added code to change the color + of the textfield to grey if the class isn't editable and to white + if the class name is editable. + 2004-06-26 08:25 Gregory John Casamento * GormPalettesManager.m: There was problem which crops up when the diff --git a/GormClassInspector.m b/GormClassInspector.m index 708d84e1..cb40304b 100644 --- a/GormClassInspector.m +++ b/GormClassInspector.m @@ -308,7 +308,8 @@ objectValueForTableColumn: (NSTableColumn *)tc [parentClass setEnabled: (isCustom && !isFirstResponder)]; [searchCell setEnabled: (isCustom && !isFirstResponder)]; [classField setEditable: (isCustom && !isFirstResponder)]; - + [classField setBackgroundColor: (isCustom?[NSColor whiteColor]:[NSColor lightGrayColor])]; + // select the parent class if(index != NSNotFound) { @@ -461,12 +462,21 @@ objectValueForTableColumn: (NSTableColumn *)tc NSString *name = [self _currentClass]; NSString *newName = [sender stringValue]; GormDocument *document = (GormDocument *)[(id )NSApp activeDocument]; + BOOL removed = NO; - [document collapseClass: name]; - [classManager renameClassNamed: name - newName: newName]; - [document reloadClasses]; - [document selectClass: newName]; + // check to see if the user wants to do this and remove the connections. + removed = [document removeConnectionsForClassNamed: name]; + + if(removed) + { + [document collapseClass: name]; + [classManager renameClassNamed: name + newName: newName]; + [nc postNotificationName: IBInspectorDidModifyObjectNotification + object: classManager]; + [document reloadClasses]; + [document selectClass: newName]; + } } - (void) clickOnClass: (id)sender diff --git a/GormDocument.m b/GormDocument.m index f231bf60..bc2e0365 100644 --- a/GormDocument.m +++ b/GormDocument.m @@ -54,7 +54,12 @@ - (BOOL) isEqual: (id)object { BOOL result = NO; - if([[self source] isEqual: [object source]] && + + if(self == object) + { + result = YES; + } + else if([[self source] isEqual: [object source]] && [[self destination] isEqual: [object destination]] && [[self label] isEqual: [object label]] && ([self class] == [object class])) @@ -2275,13 +2280,13 @@ static NSImage *classesImage = nil; // issue pre notification.. NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; [nc postNotificationName: IBWillRemoveConnectorNotification - object: self]; + object: aConnector]; // mark the document as changed. [self touch]; // issue port notification.. [connections removeObjectIdenticalTo: aConnector]; [nc postNotificationName: IBDidRemoveConnectorNotification - object: self]; + object: aConnector]; } - (void) resignSelectionForEditor: (id)editor diff --git a/GormInspectorsManager.m b/GormInspectorsManager.m index e9f88eac..ec95ac40 100644 --- a/GormInspectorsManager.m +++ b/GormInspectorsManager.m @@ -699,6 +699,20 @@ } } +- (void) _selectAction: (NSString *)action +{ + /* + * Ensure that the actions are displayed in column one, + * and select the action for the current connection (if any). + */ + [newBrowser reloadColumn: 1]; + if (action != nil) + { + [newBrowser selectRow: [actions indexOfObject: action] + inColumn: 1]; + } +} + - (void) _internalCall: (NSBrowser*)sender { unsigned numConnectors = [connectors count]; @@ -714,7 +728,6 @@ if ([title isEqual: @"target"]) { id con = nil; - NSString *action; for (index = 0; index < numConnectors; index++) { @@ -732,7 +745,7 @@ } } - if (con == nil) + if (con == nil) // && [actions containsObject: [currentConnector label]] == NO) { RELEASE(actions); actions = RETAIN([[NSApp classManager] @@ -747,21 +760,17 @@ } } + // if we changed the current connector, update to the new one... if (currentConnector != con) { ASSIGN(currentConnector, con); } + /* * Ensure that the actions are displayed in column one, * and select the action for the current connection (if any). */ - [newBrowser reloadColumn: 1]; - action = [con label]; - if (action != nil) - { - [newBrowser selectRow: [actions indexOfObject: action] - inColumn: 1]; - } + [self _selectAction: [con label]]; } else { @@ -989,8 +998,7 @@ selectCellWithString: (NSString*)title { // got the notification... since we only subscribe to one, just do what // needs to be done. - [self setObject: object]; - [self _internalCall: newBrowser]; // reload the connections browser.. + [self setObject: object]; // resets the browser... } - (id) init @@ -1055,10 +1063,12 @@ selectCellWithString: (NSString*)title [revertButton setEnabled: NO]; // catch notifications concerning connection deletions... + /* [nc addObserver: self selector: @selector(handleNotification:) name: IBDidRemoveConnectorNotification object: nil]; + */ } return self; } @@ -1109,16 +1119,17 @@ selectCellWithString: (NSString*)title if ([con isKindOfClass: [NSNibControlConnector class]]) { [[(id)NSApp activeDocument] removeConnector: con]; - [con setDestination: nil]; - [con setLabel: nil]; [connectors removeObjectIdenticalTo: con]; break; } } + + // select the new action from the list... + [self _selectAction: [currentConnector label]]; } [connectors addObject: currentConnector]; [[(id)NSApp activeDocument] addConnector: currentConnector]; - + /* * When we establish a connection, we want to highlight it in * the browser so the user can see it has been done. @@ -1141,7 +1152,7 @@ selectCellWithString: (NSString*)title NSArray *array; [super setObject: anObject]; - DESTROY(currentConnector); + // DESTROY(currentConnector); RELEASE(connectors); /*