mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-24 12:01:16 +00:00
GormBoxEditor.m GormButtonEditor.h GormButtonEditor.m GormControlEditor.h GormControlEditor.m GormInternalViewEditor.h GormInternalViewEditor.m GormMatrixEditor.h GormPlacementInfo.h GormPosingView.h GormPosingView.m GormSplitViewEditor.h GormSplitViewEditor.m GormTabViewEditor.h GormTabViewEditor.m GormViewEditor.h GormViewEditor.m GormViewWithContentViewEditor.h GormViewWithContentViewEditor.m GormViewWithSubviewsEditor.h GormViewWithSubviewsEditor.m Palettes/3Containers/GormTableViewEditor.h Palettes/3Containers/GormTableViewEditor.m ChangeLog GNUmakefile Gorm.h Gorm.m GormClassEditor.m GormClassManager.m GormCustomClassInspector.m GormCustomView.m GormDocument.m GormMatrixEditor.m GormObjectEditor.m GormOutlineView.m GormPrivate.h GormWindowEditor.m Palettes/0Menus/GormMenuEditor.m Palettes/1Windows/main.m Palettes/2Controls/GormBoxInspector.gorm Palettes/2Controls/GormButtonInspector.gorm Palettes/2Controls/GormTextFieldInspector.gorm Palettes/2Controls/main.m Palettes/3Containers/GNUmakefile Palettes/3Containers/GormNSBrowser.m Palettes/3Containers/GormNSOutlineView.m Palettes/3Containers/GormNSTableView.h Palettes/3Containers/GormTableColumnInspector.classes Palettes/3Containers/GormTableColumnInspector.gorm Palettes/3Containers/GormTableViewInspector.gorm Palettes/3Containers/inspectors.m Palettes/3Containers/main.m Palettes/4Data/inspectors.m Palettes/4Data/main.m git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@14267 72102866-910b-0410-8b05-ffd578937521
168 lines
3.7 KiB
Objective-C
168 lines
3.7 KiB
Objective-C
/* All Rights reserved */
|
|
|
|
#include <AppKit/AppKit.h>
|
|
#include "GormCustomClassInspector.h"
|
|
#include "GormPrivate.h"
|
|
#include "GormClassManager.h"
|
|
|
|
@implementation GormCustomClassInspector
|
|
+ (void) initialize
|
|
{
|
|
if (self == [GormCustomClassInspector class])
|
|
{
|
|
// TBD
|
|
}
|
|
}
|
|
|
|
- (id) init
|
|
{
|
|
self = [super init];
|
|
if (self != nil)
|
|
{
|
|
// NSDictionary *table = nil;
|
|
// NSBundle *bundle = nil;
|
|
_classManager = nil;
|
|
_currentSelection = nil;
|
|
_currentSelectionClassName = nil;
|
|
|
|
if (![NSBundle loadNibNamed: @"GormCustomClassInspector"
|
|
owner: self])
|
|
{
|
|
NSLog(@"Could not open gorm GormCustomClassInspector");
|
|
NSLog(@"self %@", self);
|
|
return nil;
|
|
}
|
|
else
|
|
{
|
|
[[NSNotificationCenter defaultCenter]
|
|
addObserver: self
|
|
selector: @selector(handleNotification:)
|
|
name: IBSelectionChangedNotification
|
|
object: nil];
|
|
}
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
|
}
|
|
|
|
- (void) _setCurrentSelectionClassName: (id)anobject
|
|
{
|
|
NSString *prefix = nil, *substring = nil;
|
|
|
|
ASSIGN(_currentSelectionClassName, NSStringFromClass([anobject class]));
|
|
prefix = [_currentSelectionClassName substringToIndex: 4];
|
|
if([prefix isEqualToString: @"Gorm"])
|
|
{
|
|
substring = [_currentSelectionClassName substringFromIndex: 4];
|
|
ASSIGN(_currentSelectionClassName, substring);
|
|
}
|
|
NSLog(@"%@",_currentSelectionClassName);
|
|
}
|
|
|
|
- (void) handleNotification: (NSNotification*)aNotification
|
|
{
|
|
id editor = [aNotification object];
|
|
|
|
if([editor respondsToSelector: @selector(document)])
|
|
{
|
|
id doc = [editor document];
|
|
NSArray *selections = [editor selection];
|
|
|
|
if([selections count] == 1)
|
|
{
|
|
_classManager = [doc classManager];
|
|
_currentSelection = [selections objectAtIndex: 0];
|
|
[self _setCurrentSelectionClassName: _currentSelection];
|
|
[browser reloadColumn: 0];
|
|
}
|
|
else
|
|
{
|
|
_currentSelection = nil;
|
|
NSLog(@"Invalid selection");
|
|
}
|
|
}
|
|
}
|
|
|
|
- (void) awakeFromNib
|
|
{
|
|
[browser setTarget: self];
|
|
[browser setAction: @selector(select:)];
|
|
}
|
|
|
|
- (void) select: (id)sender
|
|
{
|
|
/* insert your code here */
|
|
NSLog(@"Selected");
|
|
}
|
|
|
|
- (NSArray *)_additionalSubclasses
|
|
{
|
|
NSArray *result = nil;
|
|
if([_currentSelectionClassName isEqualToString: @"NSTextField"])
|
|
{
|
|
result = [NSArray arrayWithObject: @"NSSecureTextField"];
|
|
}
|
|
else if([_currentSelectionClassName isEqualToString: @"NSWindow"])
|
|
{
|
|
result = [NSArray arrayWithObject: @"NSPanel"];
|
|
}
|
|
return result;
|
|
}
|
|
|
|
// Browser delegate
|
|
|
|
- (BOOL) browser: (NSBrowser*)sender
|
|
selectRow: (int)row
|
|
inColumn: (int)column
|
|
{
|
|
return YES;
|
|
}
|
|
|
|
- (void) browser: (NSBrowser *)sender
|
|
createRowsForColumn: (int)column
|
|
inMatrix: (NSMatrix *)matrix
|
|
{
|
|
NSMutableArray *classes = [NSMutableArray arrayWithObject: _currentSelectionClassName];
|
|
NSEnumerator *e = nil;
|
|
NSString *class = nil;
|
|
NSBrowserCell *cell = nil;
|
|
int i = 0;
|
|
|
|
[classes addObjectsFromArray: [_classManager allCustomSubclassesOf: _currentSelectionClassName]];
|
|
[classes addObjectsFromArray: [self _additionalSubclasses]];
|
|
e = [classes objectEnumerator];
|
|
while((class = [e nextObject]) != nil)
|
|
{
|
|
[matrix insertRow: i withCells: nil];
|
|
cell = [matrix cellAtRow: i column: 0];
|
|
[cell setLeaf: YES];
|
|
i++;
|
|
[cell setStringValue: class];
|
|
}
|
|
}
|
|
|
|
- (NSString*) browser: (NSBrowser*)sender
|
|
titleOfColumn: (int)column
|
|
{
|
|
NSLog(@"Delegate called");
|
|
return @"Class";
|
|
}
|
|
|
|
- (void) browser: (NSBrowser *)sender
|
|
willDisplayCell: (id)cell
|
|
atRow: (int)row
|
|
column: (int)column
|
|
{
|
|
}
|
|
|
|
- (BOOL) browser: (NSBrowser *)sender
|
|
isColumnValid: (int)column
|
|
{
|
|
return YES;
|
|
}
|
|
@end
|
|
|