diff --git a/ChangeLog b/ChangeLog index 2f5662c6..fca44a89 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2003-06-06 Gregory John Casamento + + * Resources/GormClassInspector.gorm: New inspector + * GormClassInspector.[hm]: New inspector classes + * GormDocument.m: added delegate method to select class + in GormClassEditor when selected in the outline/classes view. + * GormClassManager.m: Added "touch" to appropriate methods + to fix bug which caused document to not refect that it has + been edited when a outlet/action is added. + 2003-06-01 Gregory John Casamento * Palettes/2Controls/GormNSButtonInspector.gorm: Added diff --git a/GNUmakefile b/GNUmakefile index beb9fbbc..77178dcb 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -121,6 +121,7 @@ Gorm_RESOURCE_FILES = \ Resources/GormPrefHeaders.gorm \ Resources/GormPrefGeneral.gorm \ Resources/GormScrollViewAttributesInspector.gorm \ + Resources/GormClassInspector.gorm \ Resources/Gorm.gorm Gorm_HEADERS = \ @@ -149,6 +150,7 @@ Gorm_HEADERS = \ GormPlacementInfo.h \ GormPrefController.h\ GormHeadersPref.h \ + GormClassInspector.h \ GormGeneralPref.h @@ -187,6 +189,7 @@ Gorm_OBJC_FILES = \ GormSoundEditor.m \ GormPrefController.m \ GormHeadersPref.m\ + GormClassInspector.m\ GormGeneralPref.m diff --git a/Gorm.m b/Gorm.m index 2d0733ce..1d2f650d 100644 --- a/Gorm.m +++ b/Gorm.m @@ -499,7 +499,7 @@ static NSButtonType _buttonTypeForObject( id button ) - (NSString*) inspectorClassName { - return @"GormNotApplicableInspector"; + return @"GormClassInspector"; } - (NSString*) classInspectorClassName diff --git a/GormClassInspector.h b/GormClassInspector.h new file mode 100644 index 00000000..a91a778d --- /dev/null +++ b/GormClassInspector.h @@ -0,0 +1,57 @@ +/** GormClassInspector + + allow user to select custom classes + + Copyright (C) 2002 Free Software Foundation, Inc. + Author: Gregory John Casamento + Date: September 2002 + + This file is part of GNUstep. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/* All Rights reserved */ + +#include +#include + +@class GormClassManager; + +@interface GormClassInspector : IBInspector +{ + // outlets + id actionTable; + id add; + id classField; + id outletTable; + id remove; + id tabView; + + // internal vars + NSString *currentClass; + id theobject; + id actionData; + id outletData; + + // class manager.. + GormClassManager *classManager; +} +- (void) add: (id)sender; +- (void) remove: (id)sender; +- (void) select: (id)sender; +- (NSString *) _currentClass; +@end diff --git a/GormClassInspector.m b/GormClassInspector.m new file mode 100644 index 00000000..3fcbde2f --- /dev/null +++ b/GormClassInspector.m @@ -0,0 +1,283 @@ +/** GormClassInspector + + allow user to select custom classes + + Copyright (C) 2003 Free Software Foundation, Inc. + Author: Gregory John Casamento + Date: March 2003 + + This file is part of GNUstep. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/* All Rights reserved */ + +#include +#include "GormClassInspector.h" +#include "GormPrivate.h" +#include "GormClassManager.h" +#include "GormDocument.h" + +// the data source classes for each of the tables... +@interface GormOutletDataSource : NSObject +{ + id inspector; +} +- (void) setInspector: (id)ins; +@end + +@interface GormActionDataSource : NSObject +{ + id inspector; +} +- (void) setInspector: (id)ins; +@end + +@implementation GormOutletDataSource +- (int) numberOfRowsInTableView: (NSTableView *)tv +{ + NSArray *list = [[(Gorm *)NSApp classManager] allOutletsForClassNamed: [inspector _currentClass]]; + return [list count]; +} + +- (id) tableView: (NSTableView *)tv +objectValueForTableColumn: (NSTableColumn *)tc + row: (int)rowIndex +{ + NSArray *list = [[(Gorm *)NSApp classManager] allOutletsForClassNamed: [inspector _currentClass]]; + return [list objectAtIndex: rowIndex]; +} + +- (void) tableView: (NSTableView *)tv + setObjectValue: (id)anObject + forTableColumn: (NSTableColumn *)tc + row: (int)rowIndex +{ + NSArray *list = [[(Gorm *)NSApp classManager] allOutletsForClassNamed: [inspector _currentClass]]; + NSString *name = [list objectAtIndex: rowIndex]; + + RETAIN(anObject); + [[(Gorm *)NSApp classManager] replaceOutlet: name + withOutlet: anObject + forClassNamed: [inspector _currentClass]]; +} + +// set methods +- (void) setInspector: (id)ins +{ + ASSIGN(inspector, ins); +} +@end + +@implementation GormActionDataSource +- (int) numberOfRowsInTableView: (NSTableView *)tv +{ + NSArray *list = [[(Gorm *)NSApp classManager] allActionsForClassNamed: [inspector _currentClass]]; + return [list count]; +} + +- (id) tableView: (NSTableView *)tv +objectValueForTableColumn: (NSTableColumn *)tc + row: (int)rowIndex +{ + NSArray *list = [[(Gorm *)NSApp classManager] allActionsForClassNamed: [inspector _currentClass]]; + return [list objectAtIndex: rowIndex]; +} + +- (void) tableView: (NSTableView *)tv + setObjectValue: (id)anObject + forTableColumn: (NSTableColumn *)tc + row: (int)rowIndex +{ + NSArray *list = [[(Gorm *)NSApp classManager] allActionsForClassNamed: [inspector _currentClass]]; + NSString *name = [list objectAtIndex: rowIndex]; + + RETAIN(anObject); + [[(Gorm *)NSApp classManager] replaceAction: name + withAction: anObject + forClassNamed: [inspector _currentClass]]; +} + +// set method +- (void) setInspector: (id)ins +{ + ASSIGN(inspector, ins); +} +@end + +@implementation GormClassInspector ++ (void) initialize +{ + if (self == [GormClassInspector class]) + { + // TBD + } +} + +- (id) init +{ + self = [super init]; + if (self != nil) + { + // initialize all member variables... + actionTable = nil; + add = nil; + classField = nil; + outletTable = nil; + remove = nil; + tabView = nil; + currentClass = nil; + actionData = nil; + outletData = nil; + + // load the gui... + if (![NSBundle loadNibNamed: @"GormClassInspector" + owner: self]) + { + NSLog(@"Could not open gorm GormClassInspector"); + return nil; + } + } + return self; +} + +- (void) awakeFromNib +{ + // instantiate.. + actionData = [[GormActionDataSource alloc] init]; + outletData = [[GormOutletDataSource alloc] init]; + + // initialize.. + [actionData setInspector: self]; + [outletData setInspector: self]; + + // use.. + [actionTable setDataSource: actionData]; + [outletTable setDataSource: outletData]; + + // delegate... + [actionTable setDelegate: self]; + [outletTable setDelegate: self]; +} + +- (void) _refreshView +{ + id addcell = [add cell]; + id removecell = [remove cell]; + BOOL isCustom = [classManager isCustomClass: [self _currentClass]]; + + [classField setStringValue: [self _currentClass]]; + [outletTable reloadData]; + [actionTable reloadData]; + + [addcell setEnabled: isCustom]; + [removecell setEnabled: isCustom]; +} + +- (void) add: (id)sender +{ + NSTabViewItem *tvi = [tabView selectedTabViewItem]; + if([[tvi identifier] isEqualToString: @"Actions"]) + { + [[(Gorm *)NSApp classManager] addNewActionToClassNamed: [self _currentClass]]; + [actionTable reloadData]; + } + else + { + [[(Gorm *)NSApp classManager] addNewOutletToClassNamed: [self _currentClass]]; + [outletTable reloadData]; + } +} + +- (void) remove: (id)sender +{ + NSTabViewItem *tvi = [tabView selectedTabViewItem]; + if([[tvi identifier] isEqualToString: @"Actions"]) + { + int i = [actionTable selectedRow]; + NSArray *list = [[(Gorm *)NSApp classManager] allActionsForClassNamed: [self _currentClass]]; + NSString *name = [list objectAtIndex: i]; + [[(Gorm *)NSApp classManager] removeAction: name fromClassNamed: [self _currentClass]]; + [actionTable reloadData]; + } + else + { + int i = [outletTable selectedRow]; + NSArray *list = [[(Gorm *)NSApp classManager] allOutletsForClassNamed: [self _currentClass]]; + NSString *name = [list objectAtIndex: i]; + [[(Gorm *)NSApp classManager] removeOutlet: name fromClassNamed: [self _currentClass]]; + [outletTable reloadData]; + } +} + +- (void) select: (id)sender +{ + NSLog(@"select..."); +} + +- (void) setObject: (id)anObject +{ + ASSIGN(theobject,anObject); + ASSIGN(classManager, [(Gorm *)NSApp classManager]); + RETAIN(theobject); + [self _refreshView]; +} + +- (NSString *) _currentClass +{ + return [theobject className]; +} + +- (BOOL) tableView: (NSTableView *)tableView +shouldEditTableColumn: (NSTableColumn *)aTableColumn + row: (int)rowIndex +{ + BOOL result = NO; + NSArray *list = nil; + NSString *name = nil; + NSTabViewItem *tvi = [tabView selectedTabViewItem]; + BOOL isAction = [[tvi identifier] isEqualToString: @"Actions"]; + NSString *className = [self _currentClass]; + // id classManager = [(Gorm *)NSApp classManager]; + + if(isAction) + { + list = [classManager allActionsForClassNamed: className]; + name = [list objectAtIndex: rowIndex]; + } + else + { + list = [classManager allOutletsForClassNamed: className]; + name = [list objectAtIndex: rowIndex]; + } + + if([classManager isCustomClass: className]) + { + if (isAction) + { + result = [classManager isAction: name + ofClass: className]; + } + else + { + result = [classManager isOutlet: name + ofClass: className]; + } + } + return result; +} +@end diff --git a/GormClassManager.m b/GormClassManager.m index 9a8999e9..7accef25 100644 --- a/GormClassManager.m +++ b/GormClassManager.m @@ -25,6 +25,7 @@ #include "GormPrivate.h" #include "GormCustomView.h" +#include "GormDocument.h" #include @interface GormClassManager (Private) @@ -34,12 +35,19 @@ @implementation GormClassManager +- (void) _touch +{ + id doc = [(id)NSApp activeDocument]; + [doc touch]; +} + - (void) addAction: (NSString*)anAction forObject: (id)anObject { NSMutableDictionary *info = [self classInfoForObject: anObject]; NSMutableArray *extraActions = [info objectForKey: @"ExtraActions"]; NSMutableArray *allActions = [self allActionsForObject: anObject]; + [self _touch]; if ([extraActions containsObject: anAction] == YES) { return; /* Can't add action twice. */ @@ -68,6 +76,7 @@ NSString *newClassName; int i; + [self _touch]; classInfo = [[NSMutableDictionary alloc] initWithCapacity: 3]; outlets = [[NSMutableArray alloc] initWithCapacity: 0]; actions = [[NSMutableArray alloc] initWithCapacity: 0]; @@ -103,6 +112,7 @@ NSMutableArray *combined = [NSMutableArray arrayWithArray: array]; NSString *new = @"newAction", *search = [new stringByAppendingString: @":"]; int i = 1; + [combined addObjectsFromArray: extra]; while ([combined containsObject: search]) { @@ -147,6 +157,7 @@ if (![classInformation objectForKey: className]) { + [self _touch]; classInfo = [[NSMutableDictionary alloc] initWithCapacity: 3]; [classInfo setObject: outlets forKey: @"Outlets"]; @@ -177,6 +188,7 @@ { return; /* Can't add outlet with same name. */ } + [self _touch]; if (extraOutlets == nil) { extraOutlets = [[NSMutableArray alloc] initWithCapacity: 1]; @@ -197,6 +209,7 @@ { return; } + [self _touch]; if (extraActions == nil) { extraActions = [[NSMutableArray alloc] initWithCapacity: 1]; @@ -222,6 +235,8 @@ { return; } + + [self _touch]; if (extraOutlets == nil) { extraOutlets = [[NSMutableArray alloc] initWithCapacity: 1]; @@ -253,6 +268,7 @@ int all_index = [allActions indexOfObject: oldAction]; int extra_index = [extraActions indexOfObject: oldAction]; + [self _touch]; [extraActions replaceObjectAtIndex: extra_index withObject: newAction]; [allActions replaceObjectAtIndex: all_index withObject: newAction]; } @@ -261,6 +277,7 @@ int all_index = [allActions indexOfObject: oldAction]; int actions_index = [actions indexOfObject: oldAction]; + [self _touch]; [actions replaceObjectAtIndex: actions_index withObject: newAction]; [allActions replaceObjectAtIndex: all_index withObject: newAction]; } @@ -290,6 +307,7 @@ int all_index = [allOutlets indexOfObject: oldOutlet]; int extra_index = [extraOutlets indexOfObject: oldOutlet]; + [self _touch]; [extraOutlets replaceObjectAtIndex: extra_index withObject: newOutlet]; [allOutlets replaceObjectAtIndex: all_index withObject: newOutlet]; } @@ -298,6 +316,7 @@ int all_index = [allOutlets indexOfObject: oldOutlet]; int outlets_index = [outlets indexOfObject: oldOutlet]; + [self _touch]; [outlets replaceObjectAtIndex: outlets_index withObject: newOutlet]; [allOutlets replaceObjectAtIndex: all_index withObject: newOutlet]; } @@ -768,6 +787,7 @@ { NSString *superName = [info objectForKey: @"Super"]; + [self _touch]; if (superName != nil) { NSArray *superActions; @@ -801,6 +821,7 @@ { NSString *superName = [info objectForKey: @"Super"]; + [self _touch]; if (superName != nil) { NSArray *superActions; @@ -834,10 +855,12 @@ if ([extraOutlets containsObject: anOutlet] == YES) { + [self _touch]; [extraOutlets removeObject: anOutlet]; } if ([allOutlets containsObject: anOutlet] == YES) { + [self _touch]; [allOutlets removeObject: anOutlet]; } } @@ -850,10 +873,12 @@ if ([extraOutlets containsObject: anOutlet] == YES) { + [self _touch]; [extraOutlets removeObject: anOutlet]; } if ([allOutlets containsObject: anOutlet] == YES) { + [self _touch]; [allOutlets removeObject: anOutlet]; } } @@ -862,6 +887,7 @@ { if ([customClasses containsObject: className]) { + [self _touch]; [customClasses removeObject: className]; } @@ -876,6 +902,7 @@ { int index = 0; + [self _touch]; RETAIN(classInfo); [classInformation removeObjectForKey: oldName]; diff --git a/GormDocument.m b/GormDocument.m index 337654a0..ff1a7121 100644 --- a/GormDocument.m +++ b/GormDocument.m @@ -2278,9 +2278,13 @@ static NSImage *classesImage = nil; - (void) removeConnector: (id)aConnector { + // issue pre notification.. NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; [nc postNotificationName: IBWillRemoveConnectorNotification object: self]; + // mark the document as changed. + [self touch]; + // issue port notification.. [connections removeObjectIdenticalTo: aConnector]; [nc postNotificationName: IBDidRemoveConnectorNotification object: self]; @@ -3405,6 +3409,7 @@ shouldEditTableColumn: (NSTableColumn *)tableColumn if (![item isKindOfClass: [GormOutletActionHolder class]]) { result = [classManager isCustomClass: item]; + [self editClass: item]; } else { @@ -3428,6 +3433,16 @@ shouldEditTableColumn: (NSTableColumn *)tableColumn return result; } +- (void) outlineViewSelectionDidChange: (NSNotification *)notification +{ + id object = [notification object]; + id item = [object itemAtRow: [object selectedRow]]; + if (![item isKindOfClass: [GormOutletActionHolder class]]) + { + [self editClass: item]; + } +} + // for debuging purpose - (void) printAllEditors { diff --git a/Resources/GormClassInspector.gorm/data.classes b/Resources/GormClassInspector.gorm/data.classes new file mode 100644 index 00000000..9787fdf5 --- /dev/null +++ b/Resources/GormClassInspector.gorm/data.classes @@ -0,0 +1,161 @@ +{ + FirstResponder = { + Actions = ( + "activateContextHelpMode:", + "alignCenter:", + "alignJustified:", + "alignLeft:", + "alignRight:", + "arrangeInFront:", + "cancel:", + "capitalizeWord:", + "changeColor:", + "changeFont:", + "checkSpelling:", + "close:", + "complete:", + "copy:", + "copyFont:", + "copyRuler:", + "cut:", + "delete:", + "deleteBackward:", + "deleteForward:", + "deleteToBeginningOfLine:", + "deleteToBeginningOfParagraph:", + "deleteToEndOfLine:", + "deleteToEndOfParagraph:", + "deleteToMark:", + "deleteWordBackward:", + "deleteWordForward:", + "deminiaturize:", + "deselectAll:", + "fax:", + "hide:", + "hideOtherApplications:", + "indent:", + "loosenKerning:", + "lowerBaseline:", + "lowercaseWord:", + "makeKeyAndOrderFront:", + "miniaturize:", + "miniaturizeAll:", + "moveBackward:", + "moveBackwardAndModifySelection:", + "moveDown:", + "moveDownAndModifySelection:", + "moveForward:", + "moveForwardAndModifySelection:", + "moveLeft:", + "moveRight:", + "moveToBeginningOfDocument:", + "moveToBeginningOfLine:", + "moveToBeginningOfParagraph:", + "moveToEndOfDocument:", + "moveToEndOfLine:", + "moveToEndOfParagraph:", + "moveUp:", + "moveUpAndModifySelection:", + "moveWordBackward:", + "moveWordBackwardAndModifySelection:", + "moveWordForward:", + "moveWordForwardAndModifySelection:", + "newDocument:", + "ok:", + "openDocument:", + "orderBack:", + "orderFront:", + "orderFrontColorPanel:", + "orderFrontDataLinkPanel:", + "orderFrontFontPanel:", + "orderFrontHelpPanel:", + "orderFrontStandardAboutPanel:", + "orderFrontStandardInfoPanel:", + "orderOut:", + "pageDown:", + "pageUp:", + "paste:", + "pasteAsPlainText:", + "pasteAsRichText:", + "pasteFont:", + "pasteRuler:", + "performClose:", + "performMiniaturize:", + "performZoom:", + "print:", + "raiseBaseline:", + "revertDocumentToSaved:", + "runPageLayout:", + "runToolbarCustomizationPalette:", + "saveAllDocuments:", + "saveDocument:", + "saveDocumentAs:", + "saveDocumentTo:", + "scrollLineDown:", + "scrollLineUp:", + "scrollPageDown:", + "scrollPageUp:", + "scrollViaScroller:", + "selectAll:", + "selectLine:", + "selectNextKeyView:", + "selectParagraph:", + "selectPreviousKeyView:", + "selectText:", + "selectText:", + "selectToMark:", + "selectWord:", + "showContextHelp:", + "showGuessPanel:", + "showHelp:", + "showWindow:", + "stop:", + "subscript:", + "superscript:", + "swapWithMark:", + "takeDoubleValueFrom:", + "takeFloatValueFrom:", + "takeIntValueFrom:", + "takeObjectValueFrom:", + "takeStringValueFrom:", + "terminate:", + "tightenKerning:", + "toggle:", + "toggleContinuousSpellChecking:", + "toggleRuler:", + "toggleToolbarShown:", + "toggleTraditionalCharacterShape:", + "transpose:", + "transposeWords:", + "turnOffKerning:", + "turnOffLigatures:", + "underline:", + "unhide:", + "unhideAllApplications:", + "unscript:", + "uppercaseWord:", + "useAllLigatures:", + "useStandardKerning:", + "useStandardLigatures:", + "yank:", + "zoom:" + ); + Super = NSObject; + }; + GormClassInspector = { + Actions = ( + "select:", + "remove:", + "add:" + ); + Outlets = ( + classField, + tabView, + remove, + add, + actionTable, + outletTable + ); + Super = IBInspector; + }; +} \ No newline at end of file diff --git a/Resources/GormClassInspector.gorm/objects.gorm b/Resources/GormClassInspector.gorm/objects.gorm new file mode 100644 index 00000000..be8dc769 Binary files /dev/null and b/Resources/GormClassInspector.gorm/objects.gorm differ