mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-22 22:20:44 +00:00
Add code to support selection of inspector on object load and when selected with the PopUp button
This commit is contained in:
parent
31f974643a
commit
c582a05679
4 changed files with 43 additions and 0 deletions
|
@ -1,7 +1,14 @@
|
|||
{
|
||||
"## Comment" = "Do NOT change this file, Gorm maintains it";
|
||||
FirstResponder = {
|
||||
Actions = (
|
||||
"selectInspector:"
|
||||
);
|
||||
Super = NSObject;
|
||||
};
|
||||
GormBindingsInspector = {
|
||||
Actions = (
|
||||
"selectInspector:"
|
||||
);
|
||||
Outlets = (
|
||||
"_containerView",
|
||||
|
|
Binary file not shown.
|
@ -38,9 +38,14 @@
|
|||
IBOutlet NSPopUpButton *_bindingsPopUp;
|
||||
IBOutlet NSBox *_containerView;
|
||||
|
||||
IBInspector *_inspectorObject;
|
||||
NSMutableArray *_bindingsArray;
|
||||
|
||||
NSUInteger _selectedInspectorIndex;
|
||||
}
|
||||
|
||||
- (IBAction) selectInspector: (id)sender;
|
||||
|
||||
@end
|
||||
|
||||
#endif // INCLUDED_GormBindingsInspector_h
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
|
||||
// Initialize the array that holds the inspector names...
|
||||
_bindingsArray = [[NSMutableArray alloc] initWithCapacity: 10];
|
||||
_selectedInspectorIndex = 0;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -85,10 +86,32 @@
|
|||
return title;
|
||||
}
|
||||
|
||||
- (void) _loadInspector
|
||||
{
|
||||
NSString *inspectorName = [_bindingsArray objectAtIndex: _selectedInspectorIndex];
|
||||
Class cls = NSClassFromString(inspectorName);
|
||||
|
||||
_inspectorObject = [[cls alloc] init];
|
||||
if (_inspectorObject != nil)
|
||||
{
|
||||
if (![NSBundle loadNibNamed: inspectorName owner: _inspectorObject])
|
||||
{
|
||||
NSLog(@"Could not load inspector for binding %@", inspectorName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Could not instantiate class for %@", inspectorName);
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _populatePopUp: (NSArray *)array
|
||||
{
|
||||
[_bindingsPopUp removeAllItems];
|
||||
[_bindingsArray removeAllObjects];
|
||||
|
||||
_selectedInspectorIndex = 0;
|
||||
|
||||
if ([array count] == 0 || array == nil)
|
||||
{
|
||||
|
@ -108,6 +131,8 @@
|
|||
[_bindingsArray addObject: inspector];
|
||||
}
|
||||
}
|
||||
|
||||
[self _loadInspector];
|
||||
}
|
||||
|
||||
- (void) setObject: (id)obj
|
||||
|
@ -131,4 +156,10 @@
|
|||
[super revert: sender];
|
||||
}
|
||||
|
||||
- (IBAction) selectInspector: (id)sender
|
||||
{
|
||||
_selectedInspectorIndex = [sender indexOfSelectedItem];
|
||||
[self _loadInspector];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue