mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-23 19:51:00 +00:00
Made class editor a subclass of GormOutlineView. Cleaned up some code.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@19864 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
55d5e2de75
commit
d5135b4e24
6 changed files with 391 additions and 376 deletions
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
2004-08-11 07:18 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormDocument.m: Removed the delegate and data source
|
||||
for the outline view. Changed the code in init to use
|
||||
the GormClassEditor as the outline view, instead of
|
||||
instantiating two different classes. I also changed
|
||||
the coded in other areas where "classEditor" was being
|
||||
used. Removed an uneeded method.
|
||||
* GormClassEditor.m: Added the delegate here. Added the
|
||||
initialization code from GormDocument init to the init
|
||||
method here.
|
||||
* GormPrivate.h: Made GormClassEditor into a subclass
|
||||
of GormOutlineView. This ultimately makes the code
|
||||
cleaner as it unifies the view/editor for the class
|
||||
editor.
|
||||
|
||||
2004-08-09 17:18 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormFilePrefsManager.m: The method showIncompatibilities:
|
||||
|
|
|
@ -173,7 +173,7 @@ Gorm_HEADERS = \
|
|||
GormColorsPref.h \
|
||||
GormPalettesPref.h \
|
||||
GormSoundView.h \
|
||||
GormFilePrefsManager.h
|
||||
GormFilePrefsManager.h
|
||||
|
||||
Gorm_OBJC_FILES = \
|
||||
Gorm.m \
|
||||
|
|
|
@ -1,4 +1,31 @@
|
|||
/* GormClassEditor.m
|
||||
*
|
||||
* Copyright (C) 1999, 2003 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Richard Frith-Macdonald <richard@brainstrom.co.uk>
|
||||
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
* Date: 1999, 2003
|
||||
*
|
||||
* 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"
|
||||
#include "GormClassManager.h"
|
||||
#include <AppKit/NSPasteboard.h>
|
||||
|
||||
@implementation GormClassEditor
|
||||
|
||||
|
@ -7,7 +34,58 @@
|
|||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
NSColor *salmonColor =
|
||||
[NSColor colorWithCalibratedRed: 0.850980
|
||||
green: 0.737255
|
||||
blue: 0.576471
|
||||
alpha: 1.0 ];
|
||||
NSTableColumn *tableColumn;
|
||||
|
||||
document = doc; // loose connection
|
||||
[self setDataSource: document];
|
||||
[self setDelegate: document];
|
||||
[self setAutoresizesAllColumnsToFit: YES];
|
||||
[self setAllowsColumnResizing: NO];
|
||||
[self setDrawsGrid: NO];
|
||||
[self setIndentationMarkerFollowsCell: YES];
|
||||
[self setAutoresizesOutlineColumn: YES];
|
||||
[self setIndentationPerLevel: 10];
|
||||
[self setAttributeOffset: 30];
|
||||
[self setRowHeight: 18];
|
||||
[self registerForDraggedTypes: [NSArray arrayWithObjects: NSFilenamesPboardType, nil]];
|
||||
[self setMenu: [(Gorm*)NSApp classMenu]];
|
||||
[self setBackgroundColor: salmonColor ];
|
||||
|
||||
// add the table columns...
|
||||
tableColumn = [[NSTableColumn alloc] initWithIdentifier: @"classes"];
|
||||
[[tableColumn headerCell] setStringValue: _(@"Classes")];
|
||||
[tableColumn setMinWidth: 190];
|
||||
[tableColumn setResizable: YES];
|
||||
[tableColumn setEditable: YES];
|
||||
[self addTableColumn: tableColumn];
|
||||
[self setOutlineTableColumn: tableColumn];
|
||||
RELEASE(tableColumn);
|
||||
|
||||
tableColumn = [[NSTableColumn alloc] initWithIdentifier: @"outlets"];
|
||||
[[tableColumn headerCell] setStringValue: _(@"Outlet")];
|
||||
[tableColumn setWidth: 50];
|
||||
[tableColumn setResizable: NO];
|
||||
[tableColumn setEditable: NO];
|
||||
[self addTableColumn: tableColumn];
|
||||
[self setOutletColumn: tableColumn];
|
||||
RELEASE(tableColumn);
|
||||
|
||||
tableColumn = [[NSTableColumn alloc] initWithIdentifier: @"actions"];
|
||||
[[tableColumn headerCell] setStringValue: _(@"Action")];
|
||||
[tableColumn setWidth: 50];
|
||||
[tableColumn setResizable: NO];
|
||||
[tableColumn setEditable: NO];
|
||||
[self addTableColumn: tableColumn];
|
||||
[self setActionColumn: tableColumn];
|
||||
RELEASE(tableColumn);
|
||||
|
||||
// expand all of the items in the classesView...
|
||||
[self expandItem: @"NSObject"];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -70,4 +148,287 @@
|
|||
}
|
||||
@end
|
||||
|
||||
@implementation GormDocument (NSOutlineViewDataSource)
|
||||
|
||||
// --- NSOutlineView dataSource ---
|
||||
- (id) outlineView: (NSOutlineView *)anOutlineView
|
||||
objectValueForTableColumn: (NSTableColumn *)aTableColumn
|
||||
byItem: item
|
||||
{
|
||||
id identifier = [aTableColumn identifier];
|
||||
id className = item;
|
||||
|
||||
if ([identifier isEqualToString: @"classes"])
|
||||
{
|
||||
return className;
|
||||
}
|
||||
else if ([identifier isEqualToString: @"outlets"])
|
||||
{
|
||||
return [NSString stringWithFormat: @"%d",
|
||||
[[classManager allOutletsForClassNamed: className] count]];
|
||||
}
|
||||
else if ([identifier isEqualToString: @"actions"])
|
||||
{
|
||||
return [NSString stringWithFormat: @"%d",
|
||||
[[classManager allActionsForClassNamed: className] count]];
|
||||
}
|
||||
|
||||
return @"";
|
||||
}
|
||||
|
||||
- (void) outlineView: (NSOutlineView *)anOutlineView
|
||||
setObjectValue: (id)anObject
|
||||
forTableColumn: (NSTableColumn *)aTableColumn
|
||||
byItem: (id)item
|
||||
{
|
||||
GormOutlineView *gov = (GormOutlineView *)anOutlineView;
|
||||
|
||||
// ignore object values which come in as nil...
|
||||
if(anObject == nil)
|
||||
return;
|
||||
|
||||
if ([item isKindOfClass: [GormOutletActionHolder class]])
|
||||
{
|
||||
if (![anObject isEqualToString: @""])
|
||||
{
|
||||
NSString *name = [item getName];
|
||||
|
||||
// retain the name and add the action/outlet...
|
||||
if ([gov editType] == Actions)
|
||||
{
|
||||
NSString *formattedAction = [GormDocument formatAction: anObject];
|
||||
if (![classManager isAction: formattedAction
|
||||
ofClass: [gov itemBeingEdited]])
|
||||
{
|
||||
BOOL removed;
|
||||
|
||||
removed = [self removeConnectionsWithLabel: name
|
||||
forClassNamed: [gov itemBeingEdited] isAction: YES];
|
||||
if (removed)
|
||||
{
|
||||
[classManager replaceAction: name
|
||||
withAction: formattedAction
|
||||
forClassNamed: [gov itemBeingEdited]];
|
||||
[(GormOutletActionHolder *)item setName: formattedAction];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString *message;
|
||||
|
||||
message = [NSString stringWithFormat:
|
||||
_(@"The class %@ already has an action named %@"),
|
||||
[gov itemBeingEdited], formattedAction];
|
||||
|
||||
NSRunAlertPanel(_(@"Problem Adding Action"),
|
||||
message, nil, nil, nil);
|
||||
|
||||
}
|
||||
}
|
||||
else if ([gov editType] == Outlets)
|
||||
{
|
||||
NSString *formattedOutlet = [GormDocument formatOutlet: anObject];
|
||||
|
||||
if (![classManager isOutlet: formattedOutlet
|
||||
ofClass: [gov itemBeingEdited]])
|
||||
{
|
||||
BOOL removed;
|
||||
|
||||
removed = [self removeConnectionsWithLabel: name
|
||||
forClassNamed: [gov itemBeingEdited] isAction: NO];
|
||||
if (removed)
|
||||
{
|
||||
[classManager replaceOutlet: name
|
||||
withOutlet: formattedOutlet
|
||||
forClassNamed: [gov itemBeingEdited]];
|
||||
[(GormOutletActionHolder *)item setName: formattedOutlet];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString *message;
|
||||
|
||||
message = [NSString stringWithFormat:
|
||||
_(@"The class %@ already has an outlet named %@"),
|
||||
[gov itemBeingEdited], formattedOutlet];
|
||||
NSRunAlertPanel(_(@"Problem Adding Outlet"),
|
||||
message, nil, nil, nil);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ( ![anObject isEqualToString: @""] ) && ( ! [anObject isEqualToString:item] ) )
|
||||
{
|
||||
BOOL rename;
|
||||
|
||||
rename = [self renameConnectionsForClassNamed: item toName: anObject];
|
||||
if (rename)
|
||||
{
|
||||
int row = 0;
|
||||
|
||||
// RETAIN(item); // retain the new name
|
||||
[classManager renameClassNamed: item newName: anObject];
|
||||
[gov reloadData];
|
||||
row = [gov rowForItem: anObject];
|
||||
|
||||
// make sure that item is collapsed...
|
||||
[gov expandItem: anObject];
|
||||
[gov collapseItem: anObject];
|
||||
|
||||
// scroll to the item..
|
||||
[gov scrollRowToVisible: row];
|
||||
// [gov selectRow: row byExtendingSelection: NO];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[gov setNeedsDisplay: YES];
|
||||
}
|
||||
|
||||
- (int) outlineView: (NSOutlineView *)anOutlineView
|
||||
numberOfChildrenOfItem: (id)item
|
||||
{
|
||||
if (item == nil)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSArray *subclasses = [classManager subClassesOf: item];
|
||||
return [subclasses count];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (BOOL) outlineView: (NSOutlineView *)anOutlineView
|
||||
isItemExpandable: (id)item
|
||||
{
|
||||
NSArray *subclasses = nil;
|
||||
if (item == nil)
|
||||
return YES;
|
||||
|
||||
subclasses = [classManager subClassesOf: item];
|
||||
if ([subclasses count] > 0)
|
||||
return YES;
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (id) outlineView: (NSOutlineView *)anOutlineView
|
||||
child: (int)index
|
||||
ofItem: (id)item
|
||||
{
|
||||
if (item == nil && index == 0)
|
||||
{
|
||||
return @"NSObject";
|
||||
}
|
||||
else
|
||||
{
|
||||
NSArray *subclasses = [classManager subClassesOf: item];
|
||||
return [subclasses objectAtIndex: index];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
// GormOutlineView data source methods...
|
||||
- (NSArray *)outlineView: (NSOutlineView *)anOutlineView
|
||||
actionsForItem: (id)item
|
||||
{
|
||||
NSArray *actions = [classManager allActionsForClassNamed: item];
|
||||
return actions;
|
||||
}
|
||||
|
||||
- (NSArray *)outlineView: (NSOutlineView *)anOutlineView
|
||||
outletsForItem: (id)item
|
||||
{
|
||||
NSArray *outlets = [classManager allOutletsForClassNamed: item];
|
||||
return outlets;
|
||||
}
|
||||
|
||||
- (NSString *)outlineView: (NSOutlineView *)anOutlineView
|
||||
addNewActionForClass: (id)item
|
||||
{
|
||||
GormOutlineView *gov = (GormOutlineView *)anOutlineView;
|
||||
if (![classManager isCustomClass: [gov itemBeingEdited]])
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
return [classManager addNewActionToClassNamed: item];
|
||||
}
|
||||
|
||||
- (NSString *)outlineView: (NSOutlineView *)anOutlineView
|
||||
addNewOutletForClass: (id)item
|
||||
{
|
||||
GormOutlineView *gov = (GormOutlineView *)anOutlineView;
|
||||
if (![classManager isCustomClass: [gov itemBeingEdited]])
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
if([item isEqualToString: @"FirstResponder"])
|
||||
return nil;
|
||||
|
||||
return [classManager addNewOutletToClassNamed: item];
|
||||
}
|
||||
|
||||
// Delegate methods
|
||||
- (BOOL) outlineView: (NSOutlineView *)outlineView
|
||||
shouldEditTableColumn: (NSTableColumn *)tableColumn
|
||||
item: (id)item
|
||||
{
|
||||
BOOL result = NO;
|
||||
GormOutlineView *gov = (GormOutlineView *)outlineView;
|
||||
|
||||
NSDebugLog(@"in the delegate %@", [tableColumn identifier]);
|
||||
if (tableColumn == [gov outlineTableColumn])
|
||||
{
|
||||
NSDebugLog(@"outline table col");
|
||||
if (![item isKindOfClass: [GormOutletActionHolder class]])
|
||||
{
|
||||
result = [classManager isCustomClass: item];
|
||||
[self editClass: item];
|
||||
}
|
||||
else
|
||||
{
|
||||
id itemBeingEdited = [gov itemBeingEdited];
|
||||
if ([classManager isCustomClass: itemBeingEdited])
|
||||
{
|
||||
if ([gov editType] == Actions)
|
||||
{
|
||||
result = [classManager isAction: [item getName]
|
||||
ofClass: itemBeingEdited];
|
||||
}
|
||||
else if ([gov editType] == Outlets)
|
||||
{
|
||||
result = [classManager isOutlet: [item getName]
|
||||
ofClass: itemBeingEdited];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void) outlineViewSelectionDidChange: (NSNotification *)notification
|
||||
{
|
||||
id object = [notification object];
|
||||
int row = [object selectedRow];
|
||||
|
||||
if(row != -1)
|
||||
{
|
||||
id item = [object itemAtRow: [object selectedRow]];
|
||||
if (![item isKindOfClass: [GormOutletActionHolder class]])
|
||||
{
|
||||
[self editClass: item];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end // end of data source
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
GormFilesOwner *filesOwner;
|
||||
GormFirstResponder *firstResponder;
|
||||
GormObjectProxy *fontManager;
|
||||
GormClassEditor *classEditor; // perhaps should not be here...
|
||||
NSString *documentPath;
|
||||
NSMapTable *objToName;
|
||||
NSWindow *window;
|
||||
|
@ -152,7 +151,6 @@
|
|||
- (BOOL) removeConnectionsForClassNamed: (NSString *)name;
|
||||
- (BOOL) renameConnectionsForClassNamed: (NSString *)name
|
||||
toName: (NSString *)newName;
|
||||
- (BOOL) isTopLevelObject: (id)obj;
|
||||
- (void) closeAllEditors;
|
||||
|
||||
// class loading
|
||||
|
|
383
GormDocument.m
383
GormDocument.m
|
@ -192,18 +192,12 @@ static NSImage *fileImage = nil;
|
|||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
NSRect scrollRect = {{0, 0}, {340, 188}};
|
||||
NSRect mainRect = {{20, 0}, {320, 188}};
|
||||
NSTableColumn *tableColumn;
|
||||
NSColor *salmonColor =
|
||||
[NSColor colorWithCalibratedRed: 0.850980
|
||||
green: 0.737255
|
||||
blue: 0.576471
|
||||
alpha: 1.0 ];
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
|
||||
openEditors = [NSMutableArray new];
|
||||
classManager = [[GormClassManager alloc] initWithDocument: self];
|
||||
classEditor = [[GormClassEditor alloc] initWithDocument: self];
|
||||
// classEditor = [[GormClassEditor alloc] initWithDocument: self];
|
||||
|
||||
/*
|
||||
* NB. We must retain the map values (object names) as the nameTable
|
||||
|
@ -259,14 +253,6 @@ static NSImage *fileImage = nil;
|
|||
name: IBWillEndTestingInterfaceNotification
|
||||
object: nil];
|
||||
|
||||
// selectionBox = [[NSBox alloc] initWithFrame: scrollRect];
|
||||
// [selectionBox setTitlePosition: NSNoTitle];
|
||||
// [selectionBox setBorderType: NSNoBorder];
|
||||
// [selectionBox setAutoresizingMask:
|
||||
// NSViewHeightSizable|NSViewWidthSizable];
|
||||
// [[window contentView] addSubview: selectionBox];
|
||||
// RELEASE(selectionBox);
|
||||
|
||||
// objects...
|
||||
mainRect.origin = NSMakePoint(0,0);
|
||||
scrollView = [[NSScrollView alloc] initWithFrame: scrollRect];
|
||||
|
@ -325,54 +311,15 @@ static NSImage *fileImage = nil;
|
|||
[classesScrollView setBorderType: NSBezelBorder];
|
||||
|
||||
mainRect.origin = NSMakePoint(0,0);
|
||||
classesView = [[GormOutlineView alloc] initWithFrame: mainRect];
|
||||
[classesView setMenu: [(Gorm*)NSApp classMenu]];
|
||||
[classesView setDataSource: self];
|
||||
[classesView setDelegate: self];
|
||||
[classesView setAutoresizesAllColumnsToFit: YES];
|
||||
[classesView setAllowsColumnResizing: NO];
|
||||
[classesView setDrawsGrid: NO];
|
||||
[classesView setIndentationMarkerFollowsCell: YES];
|
||||
[classesView setAutoresizesOutlineColumn: YES];
|
||||
[classesView setIndentationPerLevel: 10];
|
||||
[classesView setAttributeOffset: 30];
|
||||
[classesView setBackgroundColor: salmonColor ];
|
||||
[classesView setRowHeight: 18];
|
||||
classesView = [[GormClassEditor alloc] initWithDocument: self];
|
||||
[classesView setFrame: mainRect];
|
||||
[classesScrollView setDocumentView: classesView];
|
||||
RELEASE(classesView);
|
||||
|
||||
tableColumn = [[NSTableColumn alloc] initWithIdentifier: @"classes"];
|
||||
[[tableColumn headerCell] setStringValue: _(@"Classes")];
|
||||
[tableColumn setMinWidth: 190];
|
||||
[tableColumn setResizable: YES];
|
||||
[tableColumn setEditable: YES];
|
||||
[classesView addTableColumn: tableColumn];
|
||||
[classesView setOutlineTableColumn: tableColumn];
|
||||
RELEASE(tableColumn);
|
||||
|
||||
tableColumn = [[NSTableColumn alloc] initWithIdentifier: @"outlets"];
|
||||
[[tableColumn headerCell] setStringValue: _(@"Outlet")];
|
||||
[tableColumn setWidth: 50];
|
||||
[tableColumn setResizable: NO];
|
||||
[tableColumn setEditable: NO];
|
||||
[classesView addTableColumn: tableColumn];
|
||||
[classesView setOutletColumn: tableColumn];
|
||||
RELEASE(tableColumn);
|
||||
|
||||
tableColumn = [[NSTableColumn alloc] initWithIdentifier: @"actions"];
|
||||
[[tableColumn headerCell] setStringValue: _(@"Action")];
|
||||
[tableColumn setWidth: 50];
|
||||
[tableColumn setResizable: NO];
|
||||
[tableColumn setEditable: NO];
|
||||
[classesView addTableColumn: tableColumn];
|
||||
[classesView setActionColumn: tableColumn];
|
||||
RELEASE(tableColumn);
|
||||
|
||||
RELEASE(classesView);
|
||||
[classesView sizeToFit];
|
||||
|
||||
// expand all of the items in the classesView...
|
||||
[classesView expandItem: @"NSObject"];
|
||||
|
||||
/*
|
||||
* Set the objects view as the initial view the user's see on startup.
|
||||
*/
|
||||
[selectionBox setContentView: scrollView];
|
||||
|
||||
/*
|
||||
|
@ -752,8 +699,8 @@ static NSImage *fileImage = nil;
|
|||
int row = [classesView selectedRow];
|
||||
if (row >= 0)
|
||||
{
|
||||
[classEditor setSelectedClassName: [classesView itemAtRow: row]];
|
||||
[self setSelectionFromEditor: (id)classEditor];
|
||||
[classesView setSelectedClassName: [classesView itemAtRow: row]];
|
||||
[self setSelectionFromEditor: (id)classesView];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1072,7 +1019,7 @@ static NSImage *fileImage = nil;
|
|||
RELEASE(filePrefsView);
|
||||
|
||||
// release editors...
|
||||
RELEASE(classEditor);
|
||||
RELEASE(classesView);
|
||||
RELEASE(savedEditors);
|
||||
RELEASE(openEditors);
|
||||
|
||||
|
@ -1578,7 +1525,7 @@ static NSImage *fileImage = nil;
|
|||
[editors removeAllObjects];
|
||||
|
||||
// Close the editors in the document window...
|
||||
// don't worry about the "classEditor" since it's not really an
|
||||
// don't worry about the "classesView" since it's not really an
|
||||
// editor.
|
||||
[objectsView close];
|
||||
[imagesView close];
|
||||
|
@ -3485,290 +3432,6 @@ static NSImage *fileImage = nil;
|
|||
return removed;
|
||||
}
|
||||
|
||||
// --- NSOutlineView dataSource ---
|
||||
- (id) outlineView: (NSOutlineView *)anOutlineView
|
||||
objectValueForTableColumn: (NSTableColumn *)aTableColumn
|
||||
byItem: item
|
||||
{
|
||||
if (anOutlineView == classesView)
|
||||
{
|
||||
id identifier = [aTableColumn identifier];
|
||||
id className = item;
|
||||
|
||||
if ([identifier isEqualToString: @"classes"])
|
||||
{
|
||||
return className;
|
||||
}
|
||||
else if ([identifier isEqualToString: @"outlets"])
|
||||
{
|
||||
return [NSString stringWithFormat: @"%d",
|
||||
[[classManager allOutletsForClassNamed: className] count]];
|
||||
}
|
||||
else if ([identifier isEqualToString: @"actions"])
|
||||
{
|
||||
return [NSString stringWithFormat: @"%d",
|
||||
[[classManager allActionsForClassNamed: className] count]];
|
||||
}
|
||||
|
||||
}
|
||||
return @"";
|
||||
}
|
||||
|
||||
- (void) outlineView: (NSOutlineView *)anOutlineView
|
||||
setObjectValue: (id)anObject
|
||||
forTableColumn: (NSTableColumn *)aTableColumn
|
||||
byItem: (id)item
|
||||
{
|
||||
GormOutlineView *gov = (GormOutlineView *)anOutlineView;
|
||||
|
||||
// ignore object values which come in as nil...
|
||||
if(anObject == nil)
|
||||
return;
|
||||
|
||||
if ([item isKindOfClass: [GormOutletActionHolder class]])
|
||||
{
|
||||
if (![anObject isEqualToString: @""])
|
||||
{
|
||||
NSString *name = [item getName];
|
||||
|
||||
// retain the name and add the action/outlet...
|
||||
// RETAIN(name);
|
||||
if ([gov editType] == Actions)
|
||||
{
|
||||
NSString *formattedAction = [GormDocument formatAction: anObject];
|
||||
if (![classManager isAction: formattedAction
|
||||
ofClass: [gov itemBeingEdited]])
|
||||
{
|
||||
BOOL removed;
|
||||
|
||||
removed = [self removeConnectionsWithLabel: name
|
||||
forClassNamed: [gov itemBeingEdited] isAction: YES];
|
||||
if (removed)
|
||||
{
|
||||
[classManager replaceAction: name
|
||||
withAction: formattedAction
|
||||
forClassNamed: [gov itemBeingEdited]];
|
||||
[(GormOutletActionHolder *)item setName: formattedAction];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString *message;
|
||||
|
||||
message = [NSString stringWithFormat:
|
||||
_(@"The class %@ already has an action named %@"),
|
||||
[gov itemBeingEdited], formattedAction];
|
||||
|
||||
NSRunAlertPanel(_(@"Problem Adding Action"),
|
||||
message, nil, nil, nil);
|
||||
|
||||
}
|
||||
}
|
||||
else if ([gov editType] == Outlets)
|
||||
{
|
||||
NSString *formattedOutlet = [GormDocument formatOutlet: anObject];
|
||||
|
||||
if (![classManager isOutlet: formattedOutlet
|
||||
ofClass: [gov itemBeingEdited]])
|
||||
{
|
||||
BOOL removed;
|
||||
|
||||
removed = [self removeConnectionsWithLabel: name
|
||||
forClassNamed: [gov itemBeingEdited] isAction: NO];
|
||||
if (removed)
|
||||
{
|
||||
[classManager replaceOutlet: name
|
||||
withOutlet: formattedOutlet
|
||||
forClassNamed: [gov itemBeingEdited]];
|
||||
[(GormOutletActionHolder *)item setName: formattedOutlet];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString *message;
|
||||
|
||||
message = [NSString stringWithFormat:
|
||||
_(@"The class %@ already has an outlet named %@"),
|
||||
[gov itemBeingEdited], formattedOutlet];
|
||||
NSRunAlertPanel(_(@"Problem Adding Outlet"),
|
||||
message, nil, nil, nil);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ( ![anObject isEqualToString: @""] ) && ( ! [anObject isEqualToString:item] ) )
|
||||
{
|
||||
BOOL rename;
|
||||
|
||||
rename = [self renameConnectionsForClassNamed: item toName: anObject];
|
||||
if (rename)
|
||||
{
|
||||
int row = 0;
|
||||
|
||||
// RETAIN(item); // retain the new name
|
||||
[classManager renameClassNamed: item newName: anObject];
|
||||
[gov reloadData];
|
||||
row = [gov rowForItem: anObject];
|
||||
|
||||
// make sure that item is collapsed...
|
||||
[gov expandItem: anObject];
|
||||
[gov collapseItem: anObject];
|
||||
|
||||
// scroll to the item..
|
||||
[gov scrollRowToVisible: row];
|
||||
// [gov selectRow: row byExtendingSelection: NO];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[gov setNeedsDisplay: YES];
|
||||
}
|
||||
|
||||
- (int) outlineView: (NSOutlineView *)anOutlineView
|
||||
numberOfChildrenOfItem: (id)item
|
||||
{
|
||||
if (item == nil)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSArray *subclasses = [classManager subClassesOf: item];
|
||||
return [subclasses count];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (BOOL) outlineView: (NSOutlineView *)anOutlineView
|
||||
isItemExpandable: (id)item
|
||||
{
|
||||
NSArray *subclasses = nil;
|
||||
if (item == nil)
|
||||
return YES;
|
||||
|
||||
subclasses = [classManager subClassesOf: item];
|
||||
if ([subclasses count] > 0)
|
||||
return YES;
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (id) outlineView: (NSOutlineView *)anOutlineView
|
||||
child: (int)index
|
||||
ofItem: (id)item
|
||||
{
|
||||
if (item == nil && index == 0)
|
||||
{
|
||||
return @"NSObject";
|
||||
}
|
||||
else
|
||||
{
|
||||
NSArray *subclasses = [classManager subClassesOf: item];
|
||||
return [subclasses objectAtIndex: index];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
// GormOutlineView data source methods...
|
||||
- (NSArray *)outlineView: (NSOutlineView *)anOutlineView
|
||||
actionsForItem: (id)item
|
||||
{
|
||||
NSArray *actions = [classManager allActionsForClassNamed: item];
|
||||
return actions;
|
||||
}
|
||||
|
||||
- (NSArray *)outlineView: (NSOutlineView *)anOutlineView
|
||||
outletsForItem: (id)item
|
||||
{
|
||||
NSArray *outlets = [classManager allOutletsForClassNamed: item];
|
||||
return outlets;
|
||||
}
|
||||
|
||||
- (NSString *)outlineView: (NSOutlineView *)anOutlineView
|
||||
addNewActionForClass: (id)item
|
||||
{
|
||||
GormOutlineView *gov = (GormOutlineView *)anOutlineView;
|
||||
if (![classManager isCustomClass: [gov itemBeingEdited]])
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
return [classManager addNewActionToClassNamed: item];
|
||||
}
|
||||
|
||||
- (NSString *)outlineView: (NSOutlineView *)anOutlineView
|
||||
addNewOutletForClass: (id)item
|
||||
{
|
||||
GormOutlineView *gov = (GormOutlineView *)anOutlineView;
|
||||
if (![classManager isCustomClass: [gov itemBeingEdited]])
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
if([item isEqualToString: @"FirstResponder"])
|
||||
return nil;
|
||||
|
||||
return [classManager addNewOutletToClassNamed: item];
|
||||
}
|
||||
|
||||
// Delegate methods
|
||||
- (BOOL) outlineView: (NSOutlineView *)outlineView
|
||||
shouldEditTableColumn: (NSTableColumn *)tableColumn
|
||||
item: (id)item
|
||||
{
|
||||
BOOL result = NO;
|
||||
GormOutlineView *gov = (GormOutlineView *)outlineView;
|
||||
|
||||
NSDebugLog(@"in the delegate %@", [tableColumn identifier]);
|
||||
if (tableColumn == [gov outlineTableColumn])
|
||||
{
|
||||
NSDebugLog(@"outline table col");
|
||||
if (![item isKindOfClass: [GormOutletActionHolder class]])
|
||||
{
|
||||
result = [classManager isCustomClass: item];
|
||||
[self editClass: item];
|
||||
}
|
||||
else
|
||||
{
|
||||
id itemBeingEdited = [gov itemBeingEdited];
|
||||
if ([classManager isCustomClass: itemBeingEdited])
|
||||
{
|
||||
if ([gov editType] == Actions)
|
||||
{
|
||||
result = [classManager isAction: [item getName]
|
||||
ofClass: itemBeingEdited];
|
||||
}
|
||||
else if ([gov editType] == Outlets)
|
||||
{
|
||||
result = [classManager isOutlet: [item getName]
|
||||
ofClass: itemBeingEdited];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void) outlineViewSelectionDidChange: (NSNotification *)notification
|
||||
{
|
||||
id object = [notification object];
|
||||
int row = [object selectedRow];
|
||||
|
||||
if(row != -1)
|
||||
{
|
||||
id item = [object itemAtRow: [object selectedRow]];
|
||||
if (![item isKindOfClass: [GormOutletActionHolder class]])
|
||||
{
|
||||
[self editClass: item];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// for debuging purpose
|
||||
- (void) printAllEditors
|
||||
|
@ -3858,30 +3521,6 @@ shouldEditTableColumn: (NSTableColumn *)tableColumn
|
|||
nameTable];
|
||||
}
|
||||
|
||||
- (BOOL) isTopLevelObject: (id)obj
|
||||
{
|
||||
BOOL result = NO;
|
||||
|
||||
if ([obj isKindOfClass: [NSMenu class]] == YES)
|
||||
{
|
||||
if ([self objectForName: @"NSMenu"] == obj)
|
||||
{
|
||||
result = YES;
|
||||
}
|
||||
}
|
||||
else if ([obj isKindOfClass: [NSWindow class]] == YES)
|
||||
{
|
||||
result = YES;
|
||||
}
|
||||
else if ([obj isKindOfClass: [GSNibItem class]] == YES &&
|
||||
[obj isKindOfClass: [GormCustomView class]] == NO)
|
||||
{
|
||||
result = YES;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (id) firstResponder
|
||||
{
|
||||
return firstResponder;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "GormInspectorsManager.h"
|
||||
#include "GormClassManager.h"
|
||||
#include "GormPalettesManager.h"
|
||||
#include "GormOutlineView.h"
|
||||
|
||||
extern NSString *GormLinkPboardType;
|
||||
extern NSString *GormToggleGuidelineNotification;
|
||||
|
@ -158,7 +159,7 @@ extern NSString *GormResizeCellNotification;
|
|||
- (BOOL) documentNameIsUnique: (NSString *)filename;
|
||||
@end
|
||||
|
||||
@interface GormClassEditor : NSObject <IBSelectionOwners>
|
||||
@interface GormClassEditor : GormOutlineView <IBSelectionOwners>
|
||||
{
|
||||
GormDocument *document;
|
||||
NSString *selectedClassName;
|
||||
|
|
Loading…
Reference in a new issue