Add code to generate .gorm file names needed for each binding as well as generate the title for the popup

This commit is contained in:
Gregory John Casamento 2023-01-17 03:41:28 -05:00
parent 12c4d66809
commit de5bb26e04
9 changed files with 95 additions and 5 deletions

View file

@ -0,0 +1,12 @@
{
"## Comment" = "Do NOT change this file, Gorm maintains it";
GormBindingsInspector = {
Actions = (
);
Outlets = (
"_containerView",
"_bindingsPopUp"
);
Super = IBInspector;
};
}

Binary file not shown.

View file

@ -41,7 +41,9 @@ SUBPROJECTS = Plugins
GormCore_HEADER_FILES = \
GormCore.h \
GormAbstractDelegate.h \
GormBindingsInspector.h \
GormBoxEditor.h \
GormCore.h \
GormClassEditor.h \
GormClassInspector.h \
GormClassManager.h \
@ -103,6 +105,7 @@ GormCore_HEADER_FILES = \
GormWrapperLoader.h \
NSCell+GormAdditions.h \
NSColorWell+GormExtensions.h \
NSString+methods.h \
NSFontManager+GormExtensions.h \
NSView+GormExtensions.h \
GormGeneralPref.h \
@ -178,6 +181,7 @@ GormCore_OBJC_FILES = \
NSCell+GormAdditions.m \
NSColorWell+GormExtensions.m \
NSFontManager+GormExtensions.m \
NSString+methods.m \
NSView+GormExtensions.m \
GormPrivate.m \
GormGeneralPref.m \

View file

@ -35,7 +35,10 @@
@interface GormBindingsInspector : IBInspector
{
// outlets
IBOutlet NSPopUpButton *_bindingsPopup;
IBOutlet NSPopUpButton *_bindingsPopUp;
IBOutlet NSBox *_containerView;
NSMutableArray *_bindingsArray;
}
@end

View file

@ -31,6 +31,7 @@
#import "GormFunctions.h"
#import "GormPrivate.h"
#import "GormProtocol.h"
#import "NSString+methods.h"
@implementation GormBindingsInspector
+ (void) initialize
@ -52,14 +53,74 @@
NSLog(@"Could not open gorm file");
return nil;
}
// Initialize the array that holds the inspector names...
_bindingsArray = [[NSMutableArray alloc] initWithCapacity: 10];
}
return self;
}
- (void) dealloc
{
RELEASE(_bindingsArray);
[super dealloc];
}
- (void) awakeFromNib
{
}
- (NSString *) _mapStringToInspectorName: (NSString *)string
{
NSString *capString = [string capitalizedString];
NSString *name = [NSString stringWithFormat: @"GormBindings%@Inspector", capString];
return name;
}
- (NSString *) _mapStringToTitle: (NSString *)string
{
NSString *splitString = [string splitCamelCaseString];
NSString *title = [splitString capitalizedString];
return title;
}
- (void) _populatePopUp: (NSArray *)array
{
[_bindingsPopUp removeAllItems];
[_bindingsArray removeAllObjects];
if ([array count] == 0 || array == nil)
{
[_bindingsPopUp addItemWithTitle: @"No Bindings"];
}
else
{
NSEnumerator *en = [array objectEnumerator];
NSString *string = nil;
while ((string = [en nextObject]) != nil)
{
NSString *title = [self _mapStringToTitle: string];
NSString *inspector = [self _mapStringToInspectorName: string];
[_bindingsPopUp addItemWithTitle: title];
[_bindingsArray addObject: inspector];
}
}
}
- (void) setObject: (id)obj
{
NSArray *array = nil;
[super setObject: obj];
array = [[self object] exposedBindings];
[self _populatePopUp: array];
NSLog(@"Bindings = %@, inspectors = %@", array, _bindingsArray);
}
- (void) ok: (id)sender
{
[super ok: sender];

View file

@ -250,7 +250,7 @@
forObject: selectedObject
localizedLabel: _(@"Bindings")
inspectorClassName: [selectedObject bindingsInspectorClassName]
ordering: 4.0];
ordering: 5.0];
}
- (void) _refreshPopUp

View file

@ -3,10 +3,12 @@
#ifndef INCLUDED_NSString_methods_H
#define INCLUDED_NSString_methods_H
@import <Foundation/NSString.h>
#import <Foundation/NSString.h>
@interface NSString (Methods)
@interface NSString (methods}
- (NSString *) splitCamelCaseString;
@end
#endif

View file

@ -1,8 +1,11 @@
#import "NSString+methods.h"
#import <Foundation/NSScanner.h>
#import <Foundation/NSCharacterSet.h>
// NSString category methods to add functionality to NSString
@implementation NSString (methods)
@implementation NSString (Methods)
// Split a camel case string into a string with spaces
// e.g. "camelCaseString" becomes "camel Case String"

View file

@ -82,6 +82,11 @@
*/
- (NSString*) classInspectorClassName;
/**
* Name of bindings inspector.
*/
- (NSString*) bindingsInspectorClassName;
/**
* Name of the editor for the receiver.
*/