From 2a6f2299edb3cc10f02511cfc995a6ac6f782deb Mon Sep 17 00:00:00 2001 From: Richard Frith-MacDonald Date: Mon, 20 Dec 1999 14:20:06 +0000 Subject: [PATCH] Connection management code. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@5587 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 + ClassInformation.plist | 26 +++ GNUmakefile | 2 + Gorm.m | 16 +- GormClassManager.h | 14 ++ GormClassManager.m | 263 ++++++++++++++++++++++ GormDocument.m | 1 + GormInspectorsManager.m | 475 ++++++++++++++++++++++++++++++++++++++- GormObjectEditor.m | 19 +- GormPrivate.h | 3 + Palettes/1Windows/main.m | 48 ---- 11 files changed, 797 insertions(+), 77 deletions(-) create mode 100644 ClassInformation.plist create mode 100644 GormClassManager.h create mode 100644 GormClassManager.m diff --git a/ChangeLog b/ChangeLog index ae802566..b7fc57b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Dec 20 14:16:00 1999 Richard Frith-Macdonald + + Added connections inspector so connecting objects should work. + Use information from 'ClassInformation.plist' to specify outlets + and actions for a class. + Added GormClassManager stuff to manage this information. + Sat Dec 18 21:24:00 1999 Richard Frith-Macdonald Add partial support for draagging into object view. diff --git a/ClassInformation.plist b/ClassInformation.plist new file mode 100644 index 00000000..9c5066a8 --- /dev/null +++ b/ClassInformation.plist @@ -0,0 +1,26 @@ +{ + NSButton = { + Actions = ( + "takeStringValueFrom:" + ); + Super = NSControl; + }; + NSControl = { + Outlets = ( + target + ); + Super = NSView; + }; + NSResponder = { + Super = NSObject; + }; + NSView = { + Super = NSResponder; + }; + NSWindow = { + Outlets = ( + delegate + ); + Super = NSResponder; + }; +} diff --git a/GNUmakefile b/GNUmakefile index 31095097..ef5084ba 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -36,6 +36,7 @@ SUBPROJECTS = \ APP_NAME = Gorm Gorm_APPLICATION_ICON=Gorm.tiff Gorm_RESOURCE_FILES = \ + ClassInformation.plist \ Palettes/0Menus/0Menus.palette \ Palettes/1Windows/1Windows.palette \ Palettes/2Controls/2Controls.palette \ @@ -67,6 +68,7 @@ Gorm_OBJC_FILES = \ GormViewKnobs.m \ GormObjectEditor.m \ GormWindowEditor.m \ + GormClassManager.m \ GormInspectorsManager.m \ GormPalettesManager.m diff --git a/Gorm.m b/Gorm.m index 004adf4a..fceae4e9 100644 --- a/Gorm.m +++ b/Gorm.m @@ -83,6 +83,15 @@ NSString *GormLinkPboardType = @"GormLinkPboardType"; return YES; } +- (GormClassManager*) classManager +{ + if (classManager == nil) + { + classManager = [GormClassManager new]; + } + return classManager; +} + - (id) copy: (id)sender { if ([[selectionOwner selection] count] == 0 @@ -122,6 +131,7 @@ NSString *GormLinkPboardType = @"GormLinkPboardType"; RELEASE(inspectorsManager); RELEASE(palettesManager); RELEASE(documents); + RELEASE(classManager); [super dealloc]; } @@ -415,7 +425,7 @@ NSString *GormLinkPboardType = @"GormLinkPboardType"; - (id) save: (id)sender { - return [(id)activeDocument save: sender]; + return [(id)activeDocument saveDocument: sender]; } - (id) saveAll: (id)sender @@ -427,7 +437,7 @@ NSString *GormLinkPboardType = @"GormLinkPboardType"; { if ([[doc window] isDocumentEdited] == YES) { - [doc save: sender]; + [doc saveDocument: sender]; } } return self; @@ -435,7 +445,7 @@ NSString *GormLinkPboardType = @"GormLinkPboardType"; - (id) saveAs: (id)sender { - return [(id)activeDocument saveAs: sender]; + return [(id)activeDocument saveAsDocument: sender]; } - (id) selectAll: (id)sender diff --git a/GormClassManager.h b/GormClassManager.h new file mode 100644 index 00000000..6cd2e0e4 --- /dev/null +++ b/GormClassManager.h @@ -0,0 +1,14 @@ +#ifndef GORMCLASSMANAGER_H +#define GORMCLASSMANAGER_H + +@interface GormClassManager : NSObject +{ + NSMutableDictionary *classInformation; +} +- (NSArray*) allActionsForClass: (Class)aClass; +- (NSArray*) allActionsForClassNamed: (NSString*)className; +- (NSArray*) allOutletsForClass: (Class)aClass; +- (NSArray*) allOutletsForClassNamed: (NSString*)className; +@end + +#endif diff --git a/GormClassManager.m b/GormClassManager.m new file mode 100644 index 00000000..46eab1e8 --- /dev/null +++ b/GormClassManager.m @@ -0,0 +1,263 @@ +/* GormClassManager.m + * + * Copyright (C) 1999 Free Software Foundation, Inc. + * + * Author: Richard Frith-Macdonald + * Date: 1999 + * + * This file is part of GNUstep. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "GormPrivate.h" + +@implementation GormClassManager + +- (NSArray*) allActionsForClass: (Class)theClass +{ + NSString *className; + NSArray *actions; + + className = NSStringFromClass(theClass); + if (className == nil) + { + NSLog(@"attempt to get actions for non-existent class"); + return nil; + } + + actions = [self allActionsForClassNamed: className]; + while (actions == nil && (theClass = class_get_super_class(theClass)) != nil + && theClass != [NSObject class]) + { + className = NSStringFromClass(theClass); + actions = [self allActionsForClassNamed: className]; + } + return actions; +} + +- (NSArray*) allActionsForClassNamed: (NSString*)className +{ + NSMutableDictionary *info = [classInformation objectForKey: className]; + + if (info != nil) + { + NSMutableArray *allActions = [info objectForKey: @"AllActions"]; + + if (allActions == nil) + { + NSString *superName = [info objectForKey: @"Super"]; + NSArray *actions = [info objectForKey: @"Actions"]; + NSArray *superActions; + + if (superName == nil) + { + superActions = nil; + } + else + { + superActions = [self allActionsForClassNamed: superName]; + } + + if (superActions == nil) + { + if (actions == nil) + { + allActions = [NSMutableArray new]; + } + else + { + allActions = [actions mutableCopy]; + } + } + else + { + allActions = [superActions mutableCopy]; + if (actions != nil) + { + NSEnumerator *enumerator = [actions objectEnumerator]; + NSString *actionName; + + while ((actionName = [enumerator nextObject]) != nil) + { + if ([allActions containsObject: actionName] == NO) + { + [allActions addObject: actionName]; + } + } + [allActions sortUsingSelector: @selector(compare:)]; + } + } + [info setObject: allActions forKey: @"AllActions"]; + RELEASE(allActions); + } + return AUTORELEASE([allActions copy]); + } + return nil; +} + +- (NSArray*) allOutletsForClass: (Class)theClass +{ + NSString *className; + NSArray *outlets; + + className = NSStringFromClass(theClass); + if (className == nil) + { + NSLog(@"attempt to get outlets for non-existent class"); + return nil; + } + + outlets = [self allOutletsForClassNamed: className]; + while (outlets == nil && (theClass = class_get_super_class(theClass)) != nil + && theClass != [NSObject class]) + { + className = NSStringFromClass(theClass); + outlets = [self allOutletsForClassNamed: className]; + } + return outlets; +} + +- (NSArray*) allOutletsForClassNamed: (NSString*)className; +{ + NSMutableDictionary *info = [classInformation objectForKey: className]; + + if (info != nil) + { + NSMutableArray *allOutlets = [info objectForKey: @"AllOutlets"]; + + if (allOutlets == nil) + { + NSString *superName = [info objectForKey: @"Super"]; + NSArray *outlets = [info objectForKey: @"Outlets"]; + NSArray *superOutlets; + + if (superName == nil) + { + superOutlets = nil; + } + else + { + superOutlets = [self allOutletsForClassNamed: superName]; + } + + if (superOutlets == nil) + { + if (outlets == nil) + { + allOutlets = [NSMutableArray new]; + } + else + { + allOutlets = [outlets mutableCopy]; + } + } + else + { + allOutlets = [superOutlets mutableCopy]; + if (outlets != nil) + { + NSEnumerator *enumerator = [outlets objectEnumerator]; + NSString *outletName; + + while ((outletName = [enumerator nextObject]) != nil) + { + if ([allOutlets containsObject: outletName] == NO) + { + [allOutlets addObject: outletName]; + } + } + [allOutlets sortUsingSelector: @selector(compare:)]; + } + } + [info setObject: allOutlets forKey: @"AllOutlets"]; + RELEASE(allOutlets); + } + return AUTORELEASE([allOutlets copy]); + } + return nil; +} + +- (void) dealloc +{ + RELEASE(classInformation); + [super dealloc]; +} + +- (id) init +{ + self = [super init]; + if (self != nil) + { + NSBundle *bundle = [NSBundle mainBundle]; + NSString *path; + NSDictionary *dict; + NSEnumerator *enumerator; + NSString *key; + + path = [bundle pathForResource: @"ClassInformation" ofType: @"plist"]; + if (path == nil) + { + NSLog(@"ClassInformation.plist missing from resources"); + dict = nil; + } + else + { + dict = [NSDictionary dictionaryWithContentsOfFile: path]; + } + + /* + * Convert property-list data into a mutable structure. + */ + classInformation = [NSMutableDictionary new]; + enumerator = [dict keyEnumerator]; + while ((key = [enumerator nextObject]) != nil) + { + NSDictionary *classInfo = [dict objectForKey: key]; + NSMutableDictionary *newInfo; + id obj; + + newInfo = [NSMutableDictionary new]; + [classInformation setObject: newInfo forKey: key]; + RELEASE(newInfo); + + obj = [classInfo objectForKey: @"Super"]; + if (obj != nil) + { + [newInfo setObject: obj forKey: @"Super"]; + } + obj = [classInfo objectForKey: @"Outlets"]; + if (obj != nil) + { + obj = [obj mutableCopy]; + [obj sortUsingSelector: @selector(compare:)]; + [newInfo setObject: obj forKey: @"Outlets"]; + RELEASE(obj); + } + obj = [classInfo objectForKey: @"Actions"]; + if (obj != nil) + { + obj = [obj mutableCopy]; + [obj sortUsingSelector: @selector(compare:)]; + [newInfo setObject: obj forKey: @"Actions"]; + RELEASE(obj); + } + } + } + return self; +} + +@end + diff --git a/GormDocument.m b/GormDocument.m index 196b2b86..80cfd487 100644 --- a/GormDocument.m +++ b/GormDocument.m @@ -420,6 +420,7 @@ static NSImage *classesImage = nil; NSEnumerator *e; NSNibConnector *con; + [connections makeObjectsPerform: @selector(establishConnection)]; /* * Get links for all the top-level objects */ diff --git a/GormInspectorsManager.m b/GormInspectorsManager.m index 38e08163..588ea21b 100644 --- a/GormInspectorsManager.m +++ b/GormInspectorsManager.m @@ -24,6 +24,9 @@ #include "GormPrivate.h" +#define IVW 272 +#define IVH 388 + /* * The GormEmptyInspector is a placeholder for an empty selection. */ @@ -45,7 +48,7 @@ NSView *contents; NSButton *button; - window = [[NSWindow alloc] initWithContentRect: NSMakeRect(0, 0, 272, 360) + window = [[NSWindow alloc] initWithContentRect: NSMakeRect(0, 0, IVW, 360) styleMask: NSBorderlessWindowMask backing: NSBackingStoreRetained defer: NO]; @@ -87,7 +90,7 @@ NSView *contents; NSButton *button; - window = [[NSWindow alloc] initWithContentRect: NSMakeRect(0, 0, 272, 360) + window = [[NSWindow alloc] initWithContentRect: NSMakeRect(0, 0, IVW, 360) styleMask: NSBorderlessWindowMask backing: NSBackingStoreRetained defer: NO]; @@ -128,7 +131,7 @@ NSView *contents; NSButton *button; - window = [[NSWindow alloc] initWithContentRect: NSMakeRect(0, 0, 272, 360) + window = [[NSWindow alloc] initWithContentRect: NSMakeRect(0, 0, IVW, 360) styleMask: NSBorderlessWindowMask backing: NSBackingStoreRetained defer: NO]; @@ -200,11 +203,12 @@ - (id) init { NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + NSBox *bar; NSMenuItem *item; - NSRect contentRect = {{0, 0}, {272, 420}}; - NSRect popupRect = {{60, 15}, {152, 20}}; - NSRect selectionRect = {{0, 380}, {272, 40}}; - NSRect inspectorRect = {{0, 0}, {272, 378}}; + NSRect contentRect = {{0, 0}, {IVW, 420}}; + NSRect popupRect = {{60, 5}, {152, 20}}; + NSRect selectionRect = {{0, 390}, {IVW, 30}}; + NSRect inspectorRect = {{0, 0}, {IVW, IVH}}; unsigned int style = NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask; panel = [[NSPanel alloc] initWithContentRect: contentRect @@ -261,6 +265,13 @@ [item setKeyEquivalent: @"4"]; [item setTag: 3]; + bar = [[NSBox alloc] initWithFrame: NSMakeRect (0, 0, IVW, 2)]; + [bar setBorderType: NSGrooveBorder]; + [bar setTitlePosition: NSNoTitle]; + [bar setAutoresizingMask: NSViewWidthSizable|NSViewMinYMargin]; + [selectionView addSubview: bar]; + RELEASE(bar); + /* * The inspector view fills the area below the selection view. */ @@ -308,6 +319,7 @@ [popup selectItemAtIndex: 1]; [popup setNeedsDisplay: YES]; [panel makeKeyAndOrderFront: self]; + current = 1; } [self setCurrentInspector: self]; } @@ -341,6 +353,8 @@ * Return the inspector view to its original window and release the old * inspector. */ + [[inspector okButton] removeFromSuperview]; + [[inspector revertButton] removeFromSuperview]; [[inspector window] setContentView: [[inspectorView subviews] lastObject]]; DESTROY(inspector); @@ -446,10 +460,449 @@ [newView setFrame: rect]; [inspectorView addSubview: newView]; } - /* - * Tell inspector to update from its object. - */ - [inspector revert: self]; } @end + + +@interface GormConnectionInspector : IBInspector +{ + id currentConnector; + NSMutableArray *connectors; + NSArray *actions; + NSArray *outlets; + NSBrowser *newBrowser; + NSBrowser *oldBrowser; +} +- (void) updateButtons; +@end + +@implementation GormConnectionInspector + +- (int) browser: (NSBrowser*)sender numberOfRowsInColumn: (int)column +{ + int rows = 0; + + if (sender == newBrowser) + { + if (column == 0) + { + rows = [outlets count]; + } + else + { + NSString *name = [[sender selectedCellInColumn: 0] stringValue]; + + if ([name isEqual: @"target"]) + { + rows = [actions count]; + } + } + } + else + { + rows = [connectors count]; + } + return rows; +} + +- (NSString*) browser: (NSBrowser*)sender titleOfColumn: (int)column +{ + if (sender == newBrowser) + { + if (column == 0) + { + return @"Outlets"; + } + else + { + NSString *name = [[sender selectedCellInColumn: 0] stringValue]; + + if ([name isEqual: @"target"]) + { + return @"Actions"; + } + else + { + return @""; + } + } + } + else + { + return @"Connections"; + } +} + +- (BOOL) browser: (NSBrowser*)sender +selectCellWithString: (NSString*)title + inColumn: (int)col +{ + unsigned numConnectors = [connectors count]; + unsigned index; + + if (sender == newBrowser) + { + if (col == 0) + { + if ([title isEqual: @"target"]) + { + if (actions == nil) + { + actions = [[NSApp classManager] allActionsForClassNamed: + NSStringFromClass([[NSApp connectDestination] class])]; + RETAIN(actions); + } + for (index = 0; index < numConnectors; index++) + { + id con = [connectors objectAtIndex: index]; + + if ([con isKindOfClass: [NSNibControlConnector class]] == YES) + { + NSString *action = [con label]; + + ASSIGN(currentConnector, con); + [newBrowser selectRow: [actions indexOfObject: action] + inColumn: 1]; + [oldBrowser selectRow: index inColumn: 0]; + [NSApp displayConnectionBetween: object + and: [con destination]]; + break; + } + } + } + else + { + BOOL found = NO; + + /* + * See if there already exists a connector for this outlet. + */ + for (index = 0; index < numConnectors; index++) + { + id con = [connectors objectAtIndex: index]; + + if ([[con label] isEqual: title] == YES) + { + ASSIGN(currentConnector, con); + [oldBrowser selectRow: index inColumn: 0]; + [NSApp displayConnectionBetween: object + and: [con destination]]; + found = YES; + break; + } + } + /* + * if there was no connector, make one. + */ + if (found == NO) + { + RELEASE(currentConnector); + currentConnector = [NSNibOutletConnector new]; + [currentConnector setSource: object]; + [currentConnector setDestination: [NSApp connectDestination]]; + [currentConnector setLabel: title]; + [oldBrowser loadColumnZero]; + [oldBrowser selectRow: index inColumn: 0]; + } + } + } + else + { + BOOL found = NO; + + for (index = 0; index < numConnectors; index++) + { + id con = [connectors objectAtIndex: index]; + + if ([con isKindOfClass: [NSNibControlConnector class]] == YES) + { + NSString *action = [con label]; + + if ([action isEqual: title] == YES) + { + ASSIGN(currentConnector, con); + found = YES; + break; + } + } + } + if (found == NO) + { + RELEASE(currentConnector); + currentConnector = [NSNibControlConnector new]; + [currentConnector setSource: object]; + [currentConnector setDestination: [NSApp connectDestination]]; + [currentConnector setLabel: title]; + [oldBrowser loadColumnZero]; + } + [oldBrowser selectRow: index inColumn: 0]; + } + } + else + { + for (index = 0; index < numConnectors; index++) + { + id con = [connectors objectAtIndex: index]; + + if ([title hasPrefix: [con label]] == YES) + { + NSString *label; + NSString *name; + id dest = [NSApp connectDestination]; + + label = [con label]; + dest = [con destination]; + name = [[(id)NSApp activeDocument] nameForObject: dest]; + name = [label stringByAppendingFormat: @" (%@)", name]; + if ([title isEqual: name] == YES) + { + ASSIGN(currentConnector, con); + [NSApp displayConnectionBetween: object + and: [con destination]]; + break; + } + } + } + } + [self updateButtons]; + return YES; +} + +- (void) browser: (NSBrowser*)sender + willDisplayCell: (id)aCell + atRow: (int)row + column: (int)col +{ + if (sender == newBrowser) + { + NSString *name; + + if (col == 0) + { + if (row >= 0 && row < [outlets count]) + { + name = [outlets objectAtIndex: row]; + [aCell setStringValue: name]; + if ([name isEqual: @"target"]) + { + [aCell setLeaf: NO]; + } + else + { + [aCell setLeaf: YES]; + } + [aCell setEnabled: YES]; + } + else + { + [aCell setStringValue: @""]; + [aCell setLeaf: YES]; + [aCell setEnabled: NO]; + } + } + else + { + name = [[sender selectedCellInColumn: 0] stringValue]; + if ([name isEqual: @"target"] == NO) + { + NSLog(@"cell selected in actions column without target"); + } + if (row >= 0 && row < [actions count]) + { + [aCell setStringValue: [actions objectAtIndex: row]]; + [aCell setEnabled: YES]; + } + else + { + [aCell setStringValue: @""]; + [aCell setEnabled: NO]; + } + [aCell setLeaf: YES]; + } + } + else + { + if (row >= 0 && row < [connectors count]) + { + NSString *label; + NSString *name; + id dest = [NSApp connectDestination]; + + label = [[connectors objectAtIndex: row] label]; + dest = [[connectors objectAtIndex: row] destination]; + name = [[(id)NSApp activeDocument] nameForObject: dest]; + name = [label stringByAppendingFormat: @" (%@)", name]; + + [aCell setStringValue: name]; + [aCell setEnabled: YES]; + } + else + { + [aCell setStringValue: @""]; + [aCell setEnabled: NO]; + } + [aCell setLeaf: YES]; + } +} + +- (void) dealloc +{ + RELEASE(currentConnector); + RELEASE(connectors); + RELEASE(actions); + RELEASE(outlets); + RELEASE(okButton); + RELEASE(revertButton); + RELEASE(window); + [super dealloc]; +} + +- (id) init +{ + self = [super init]; + if (self != nil) + { + NSView *contents; + NSSplitView *split; + NSArray *array; + NSRect rect; + id obj; + + obj = [[[(Gorm*)NSApp selectionOwner] selection] lastObject]; + + /* + * Create list of existing connections for selected object. + */ + connectors = [NSMutableArray new]; + array = [[(id)NSApp activeDocument] connectorsForSource: obj + ofClass: [NSNibControlConnector class]]; + [connectors addObjectsFromArray: array]; + array = [[(id)NSApp activeDocument] connectorsForSource: obj + ofClass: [NSNibOutletConnector class]]; + [connectors addObjectsFromArray: array]; + + outlets = RETAIN([[NSApp classManager] allOutletsForClassNamed: + NSStringFromClass([obj class])]); + + rect = NSMakeRect(0, 0, IVW, IVH); + window = [[NSWindow alloc] initWithContentRect: rect + styleMask: NSBorderlessWindowMask + backing: NSBackingStoreRetained + defer: NO]; + contents = [window contentView]; + split = [[NSSplitView alloc] initWithFrame: [contents bounds]]; + [split setAutoresizingMask: NSViewWidthSizable|NSViewHeightSizable]; + + newBrowser = [[NSBrowser alloc] initWithFrame: rect]; + [newBrowser setAutoresizingMask: NSViewWidthSizable|NSViewHeightSizable]; + [newBrowser setMaxVisibleColumns: 2]; + [newBrowser setAllowsMultipleSelection: NO]; + [newBrowser setHasHorizontalScroller: NO]; + [newBrowser setDelegate: self]; + + [split addSubview: newBrowser]; + RELEASE(newBrowser); + + rect.size.height /= 2; + oldBrowser = [[NSBrowser alloc] initWithFrame: rect]; + [oldBrowser setAutoresizingMask: NSViewWidthSizable|NSViewHeightSizable]; + [oldBrowser setMaxVisibleColumns: 1]; + [oldBrowser setAllowsMultipleSelection: NO]; + [oldBrowser setHasHorizontalScroller: NO]; + [oldBrowser setDelegate: self]; + + [split addSubview: oldBrowser]; + RELEASE(oldBrowser); + + [contents addSubview: split]; + RELEASE(split); + + /* + * See if we can do initial selection based on pre-existing connections. + */ + if ([NSApp isConnecting] == YES) + { + id dest = [NSApp connectDestination]; + unsigned row; + + for (row = 0; row < [connectors count]; row++) + { + id con = [connectors objectAtIndex: row]; + + if ([con destination] == dest) + { + ASSIGN(currentConnector, con); + [oldBrowser selectRow: row inColumn: 0]; + break; + } + } + } + + okButton = [[NSButton alloc] initWithFrame: NSMakeRect(0,0,60,20)]; + [okButton setAutoresizingMask: NSViewMaxYMargin | NSViewMinXMargin]; + [okButton setAction: @selector(ok:)]; + [okButton setTarget: self]; + [okButton setTitle: @"Connect"]; + [okButton setEnabled: NO]; + + revertButton = [[NSButton alloc] initWithFrame: NSMakeRect(0,0,60,20)]; + [revertButton setAutoresizingMask: NSViewMaxYMargin | NSViewMinXMargin]; + [revertButton setAction: @selector(revert:)]; + [revertButton setTarget: self]; + [revertButton setTitle: @"Revert"]; + [revertButton setEnabled: NO]; + + if (currentConnector == nil) + { + if ([outlets count] == 1) + { + [newBrowser selectRow: 0 inColumn: 0]; + } + } + [self updateButtons]; + } + return self; +} + +- (void) ok: (id)sender +{ + if ([connectors containsObject: currentConnector] == YES) + { + [[(id)NSApp activeDocument] removeConnector: currentConnector]; + [connectors removeObject: currentConnector]; + } + else + { + [connectors addObject: currentConnector]; + [[(id)NSApp activeDocument] addConnector: currentConnector]; + } + [self updateButtons]; +} + +- (void) updateButtons +{ + if (currentConnector == nil) + { + [okButton setEnabled: NO]; + } + else + { + [okButton setEnabled: YES]; + if ([connectors containsObject: currentConnector] == YES) + { + [okButton setTitle: @"Disconnect"]; + } + else + { + [okButton setTitle: @"Connect"]; + } + } +} + +- (BOOL) wantsButtons +{ + return YES; +} +@end + diff --git a/GormObjectEditor.m b/GormObjectEditor.m index cd534ef4..843953b8 100644 --- a/GormObjectEditor.m +++ b/GormObjectEditor.m @@ -35,7 +35,7 @@ } - (NSString*) connectInspectorClassName { - return @"GormObjectInspector"; + return @"GormConnectionInspector"; } - (NSString*) sizeInspectorClassName { @@ -116,14 +116,7 @@ static NSMapTable *docMap = 0; if (index >= 0 && index < [objects count]) { obj = [objects objectAtIndex: index]; - if (obj != selected) - { - NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - - selected = obj; - [nc postNotificationName: IBSelectionChangedNotification - object: self]; - } + [self selectObjects: [NSArray arrayWithObject: obj]]; } return obj; } @@ -352,7 +345,6 @@ static NSMapTable *docMap = 0; { [self selectObjects: [NSArray arrayWithObject: obj]]; [self makeSelectionVisible: YES]; - [self makeSelectionVisible: YES]; } name = [document nameForObject: obj]; if ([name isEqualToString: @"NSFirst"] == NO) @@ -598,11 +590,8 @@ NSLog(@"Got link from %@", name); { id obj = [anArray lastObject]; - if (obj != selected) - { - selected = obj; - [document setSelectionFromEditor: self]; - } + selected = obj; + [document setSelectionFromEditor: self]; } - (NSArray*) selection diff --git a/GormPrivate.h b/GormPrivate.h index e052dba1..60529f81 100644 --- a/GormPrivate.h +++ b/GormPrivate.h @@ -9,11 +9,13 @@ #include "GormDocument.h" #include "GormInspectorsManager.h" +#include "GormClassManager.h" #include "GormPalettesManager.h" extern NSString *GormLinkPboardType; @interface NSApplication (Gorm) +- (GormClassManager*) classManager; - (NSImage*) linkImage; - (void) startConnecting; @end @@ -21,6 +23,7 @@ extern NSString *GormLinkPboardType; @interface Gorm : NSApplication { id infoPanel; + GormClassManager *classManager; GormInspectorsManager *inspectorsManager; GormPalettesManager *palettesManager; id selectionOwner; diff --git a/Palettes/1Windows/main.m b/Palettes/1Windows/main.m index 03c45c78..a5fea9fb 100644 --- a/Palettes/1Windows/main.m +++ b/Palettes/1Windows/main.m @@ -133,22 +133,6 @@ { return @"GormWindowAttributesInspector"; } -- (NSString*) connectInspectorClassName -{ - return @"GormWindowConnectionsInspector"; -} -- (NSString*) sizeInspectorClassName -{ - return @"GormWindowSizeInspector"; -} -- (NSString*) helpInspectorClassName -{ - return @"GormWindowHelpInspector"; -} -- (NSString*) classInspectorClassName -{ - return @"GormWindowClassInspector"; -} @end @@ -186,35 +170,3 @@ } @end - - -@interface GormWindowConnectionsInspector : IBInspector -@end - -@implementation GormWindowConnectionsInspector -@end - - - -@interface GormWindowSizeInspector : IBInspector -@end - -@implementation GormWindowSizeInspector -@end - - - -@interface GormWindowHelpInspector : IBInspector -@end - -@implementation GormWindowHelpInspector -@end - - - -@interface GormWindowClassInspector : IBInspector -@end - -@implementation GormWindowClassInspector -@end -