Adding new inspector for classes.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@16872 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2003-06-06 06:24:46 +00:00
parent e3733a243d
commit ba5c344474
9 changed files with 557 additions and 1 deletions

View file

@ -1,3 +1,13 @@
2003-06-06 Gregory John Casamento <greg_casamento@yahoo.com>
* 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 <greg_casamento@yahoo.com>
* Palettes/2Controls/GormNSButtonInspector.gorm: Added

View file

@ -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

2
Gorm.m
View file

@ -499,7 +499,7 @@ static NSButtonType _buttonTypeForObject( id button )
- (NSString*) inspectorClassName
{
return @"GormNotApplicableInspector";
return @"GormClassInspector";
}
- (NSString*) classInspectorClassName

57
GormClassInspector.h Normal file
View file

@ -0,0 +1,57 @@
/** <title>GormClassInspector</title>
<abstract>allow user to select custom classes</abstract>
Copyright (C) 2002 Free Software Foundation, Inc.
Author: Gregory John Casamento <greg_casamento@yahoo.com>
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 <AppKit/AppKit.h>
#include <InterfaceBuilder/IBInspector.h>
@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

283
GormClassInspector.m Normal file
View file

@ -0,0 +1,283 @@
/** <title>GormClassInspector</title>
<abstract>allow user to select custom classes</abstract>
Copyright (C) 2003 Free Software Foundation, Inc.
Author: Gregory John Casamento <greg_casamento@yahoo.com>
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 <AppKit/AppKit.h>
#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

View file

@ -25,6 +25,7 @@
#include "GormPrivate.h"
#include "GormCustomView.h"
#include "GormDocument.h"
#include <InterfaceBuilder/IBEditors.h>
@interface GormClassManager (Private)
@ -34,12 +35,19 @@
@implementation GormClassManager
- (void) _touch
{
id<IBDocuments> doc = [(id<IB>)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];

View file

@ -2278,9 +2278,13 @@ static NSImage *classesImage = nil;
- (void) removeConnector: (id<IBConnectors>)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
{

View file

@ -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;
};
}

Binary file not shown.