2006-12-26 11:00:33 +00:00
|
|
|
/*
|
|
|
|
GNUstep ProjectCenter - http://www.gnustep.org/experience/ProjectCenter.html
|
|
|
|
|
|
|
|
Copyright (C) 2001 Free Software Foundation
|
|
|
|
|
|
|
|
Author: Serg Stoyan <stoyan@on.com.ua>
|
|
|
|
|
|
|
|
This file is part of GNUstep.
|
|
|
|
|
|
|
|
This application 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 application 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 General Public
|
|
|
|
License along with this library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ProjectCenter/PCMakefileFactory.h>
|
|
|
|
|
|
|
|
#include "PCAppProject+Inspector.h"
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// --- Customized text field
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification";
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
static void
|
|
|
|
setOrRemove(NSMutableDictionary *m, id v, NSString *k)
|
|
|
|
{
|
|
|
|
if ([v isKindOfClass: [NSString class]])
|
|
|
|
{
|
|
|
|
v = [v stringByTrimmingSpaces];
|
|
|
|
if ([v length] == 0)
|
|
|
|
v = nil;
|
|
|
|
}
|
|
|
|
else if ([v isKindOfClass: [NSArray class]])
|
|
|
|
{
|
|
|
|
if ([v count] == 0)
|
|
|
|
v = nil;
|
|
|
|
}
|
|
|
|
if (v == nil)
|
|
|
|
[m removeObjectForKey: k];
|
|
|
|
else
|
|
|
|
[m setObject: v forKey: k];
|
|
|
|
}
|
|
|
|
|
|
|
|
static id
|
|
|
|
cleanup(NSMutableDictionary *m, NSString *k)
|
|
|
|
{
|
|
|
|
id v;
|
|
|
|
|
|
|
|
setOrRemove(m, [m objectForKey: k], k);
|
|
|
|
v = [m objectForKey: k];
|
|
|
|
if (v == nil)
|
|
|
|
v = @"";
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-26 11:00:33 +00:00
|
|
|
@implementation PCAppTextField
|
|
|
|
|
|
|
|
- (BOOL)becomeFirstResponder
|
|
|
|
{
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
postNotificationName:PCITextFieldGetFocus
|
|
|
|
object:self];
|
|
|
|
|
|
|
|
return [super becomeFirstResponder];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation PCAppProject (Inspector)
|
|
|
|
|
|
|
|
- (void)awakeFromNib
|
|
|
|
{
|
|
|
|
[docBasedAppButton setRefusesFirstResponder:YES];
|
|
|
|
|
|
|
|
[docBasedAppButton setState:
|
2008-12-17 07:04:14 +00:00
|
|
|
([[projectDict objectForKey: PCDocumentBasedApp]
|
2006-12-26 11:00:33 +00:00
|
|
|
isEqualToString: @"YES"]) ? NSOnState : NSOffState];
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// --- User Interface
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
- (void)createProjectAttributes
|
|
|
|
{
|
|
|
|
// TFs Buttons
|
2008-12-17 07:04:14 +00:00
|
|
|
[setFieldButton setRefusesFirstResponder: YES];
|
|
|
|
[clearFieldButton setRefusesFirstResponder: YES];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
|
|
|
// Document types buttons
|
2008-12-17 07:04:14 +00:00
|
|
|
[addDocTypeButton setRefusesFirstResponder: YES];
|
|
|
|
[removeDocTypeButton setRefusesFirstResponder: YES];
|
|
|
|
[docBasedAppButton setRefusesFirstResponder: YES];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[self setDocBasedApp: docBasedAppButton];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[[NSNotificationCenter defaultCenter] addObserver: self
|
|
|
|
selector: @selector(tfGetFocus:)
|
|
|
|
name: PCITextFieldGetFocus
|
|
|
|
object: nil];
|
2006-12-26 11:00:33 +00:00
|
|
|
[projectAttributesView retain];
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[self updateInspectorValues: nil];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSView *)projectAttributesView
|
|
|
|
{
|
|
|
|
if (!projectAttributesView)
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
if ([NSBundle loadNibNamed: @"Inspector" owner: self] == NO)
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
NSLog(@"PCAppProject: error loading Inspector NIB!");
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
[self createProjectAttributes];
|
|
|
|
}
|
|
|
|
|
|
|
|
return projectAttributesView;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// --- Actions
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
- (void)setAppType: (id)sender
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
NSString *appType = [appTypeField stringValue];
|
2008-12-17 07:04:14 +00:00
|
|
|
NSMutableArray *libs = [[projectDict objectForKey: PCLibraries] mutableCopy];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
if ([appType isEqualToString: @"Renaissance"])
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[libs addObject: @"Renaissance"];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[libs removeObject: @"Renaissance"];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[self setProjectDictObject: libs forKey: PCLibraries notify: YES];
|
2006-12-26 11:00:33 +00:00
|
|
|
RELEASE(libs);
|
2008-12-17 07:04:14 +00:00
|
|
|
[self setProjectDictObject: appType forKey: PCAppType notify: YES];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
- (void)setAppClass: (id)sender
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[self setProjectDictObject: [appClassField stringValue]
|
|
|
|
forKey: PCPrincipalClass
|
|
|
|
notify: YES];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
- (void)setIconViewImage: (NSImage *)image
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[iconView setImage: nil];
|
2006-12-26 11:00:33 +00:00
|
|
|
[iconView display];
|
|
|
|
|
|
|
|
if (image == nil)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[iconView setImage: image];
|
2006-12-26 11:00:33 +00:00
|
|
|
[iconView display];
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
- (void)setFile: (id)sender
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
if (!activeTextField)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (activeTextField == appImageField)
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[self setAppIcon: self];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
else if (activeTextField == helpFileField)
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[self setHelpFile: self];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
else if (activeTextField == mainNIBField)
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[self setMainNib: self];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
- (void)clearFile: (id)sender
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
if (!activeTextField)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (activeTextField == appImageField)
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[self clearAppIcon: self];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
else if (activeTextField == helpFileField)
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[self clearHelpFile: self];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
else if (activeTextField == mainNIBField)
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[self clearMainNib: self];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
2008-12-17 07:04:14 +00:00
|
|
|
[self setIconViewImage: nil];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Application Icon
|
2008-12-17 07:04:14 +00:00
|
|
|
- (void)setAppIcon: (id)sender
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
int result;
|
|
|
|
NSArray *fileTypes = [NSImage imageFileTypes];
|
|
|
|
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
|
|
|
|
NSString *dir = nil;
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[openPanel setAllowsMultipleSelection: NO];
|
|
|
|
[openPanel setTitle: @"Set Application Icon"];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
|
|
|
dir = [[NSUserDefaults standardUserDefaults]
|
2008-12-17 07:04:14 +00:00
|
|
|
objectForKey: @"LastOpenDirectory"];
|
|
|
|
result = [openPanel runModalForDirectory: dir
|
|
|
|
file: nil
|
|
|
|
types: fileTypes];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
|
|
|
if (result == NSOKButton)
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
NSString *imageFilePath = [[openPanel filenames] objectAtIndex: 0];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
if (![self setAppIconWithImageAtPath: imageFilePath])
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
NSRunAlertPanel(@"Error while opening file!",
|
|
|
|
@"Couldn't open %@", @"OK", nil, nil,imageFilePath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
- (void)setHelpFile: (id)sender
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
NSArray *fileTypes = [NSArray arrayWithObject: @"rtfd"];
|
|
|
|
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
|
|
|
|
NSString *dir = nil;
|
|
|
|
|
|
|
|
[openPanel setAllowsMultipleSelection: NO];
|
|
|
|
[openPanel setTitle: @"Set Help File"];
|
|
|
|
|
|
|
|
dir = [[NSUserDefaults standardUserDefaults]
|
|
|
|
objectForKey: @"LastOpenDirectory"];
|
|
|
|
result = [openPanel runModalForDirectory: dir
|
|
|
|
file: nil
|
|
|
|
types: fileTypes];
|
|
|
|
|
|
|
|
if (result == NSOKButton)
|
|
|
|
{
|
|
|
|
NSString *path = [[openPanel filenames] objectAtIndex: 0];
|
|
|
|
NSString *file = [path lastPathComponent];
|
|
|
|
|
|
|
|
[helpFileField setStringValue: file];
|
|
|
|
|
|
|
|
[self addAndCopyFiles: [NSArray arrayWithObject: path]
|
|
|
|
forKey: PCDocuFiles];
|
|
|
|
|
|
|
|
[infoDict setObject: file forKey: @"GSHelpContentsFile"];
|
|
|
|
[self setProjectDictObject: file forKey: PCHelpFile notify: YES];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)clearAppIcon: (id)sender
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[appImageField setStringValue: @""];
|
|
|
|
[infoDict setObject: @"" forKey: @"NSIcon"];
|
|
|
|
[infoDict setObject: @"" forKey: @"ApplicationIcon"];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[self setProjectDictObject: @"" forKey: PCAppIcon notify: YES];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
- (void)clearHelpFile: (id)sender
|
|
|
|
{
|
|
|
|
[infoDict removeObjectForKey: @"GSHelpContentsFile"];
|
|
|
|
[self setProjectDictObject: @"" forKey: PCHelpFile notify: YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)setAppIconWithImageAtPath: (NSString *)path
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
NSImage *image = nil;
|
|
|
|
NSString *imageName = nil;
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
if (!(image = [[NSImage alloc] initWithContentsOfFile: path]))
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
imageName = [path lastPathComponent];
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[appImageField setStringValue: imageName];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[self setIconViewImage: image];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[self addAndCopyFiles: [NSArray arrayWithObject: path] forKey: PCImages];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[infoDict setObject: imageName forKey: @"NSIcon"];
|
|
|
|
[infoDict setObject: imageName forKey: @"ApplicationIcon"];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[self setProjectDictObject: imageName forKey: PCAppIcon notify: YES];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Main Interface File
|
2008-12-17 07:04:14 +00:00
|
|
|
- (void)setMainNib: (id)sender
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
int result;
|
|
|
|
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
|
|
|
|
NSString *dir = nil;
|
|
|
|
NSArray *types = nil;
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[openPanel setAllowsMultipleSelection: NO];
|
|
|
|
[openPanel setTitle: @"Set Main Interface File"];
|
|
|
|
if ([[projectDict objectForKey: PCAppType] isEqualToString: @"GORM"])
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
types = [NSArray arrayWithObject: @"gorm"];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
types = [NSArray arrayWithObject: @"gsmarkup"];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dir = [[NSUserDefaults standardUserDefaults]
|
2008-12-17 07:04:14 +00:00
|
|
|
objectForKey: @"LastOpenDirectory"];
|
|
|
|
result = [openPanel runModalForDirectory: dir file: nil types: types];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
|
|
|
if (result == NSOKButton)
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
NSString *file = [[openPanel filenames] objectAtIndex: 0];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
if (![self setMainNibWithFileAtPath: file])
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
NSRunAlertPanel(@"Error while opening file!",
|
|
|
|
@"Couldn't open %@", @"OK", nil, nil,file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
- (BOOL)setMainNibWithFileAtPath: (NSString *)path
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
NSString *nibName = [path lastPathComponent];
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[self setIconViewImage: [[NSWorkspace sharedWorkspace] iconForFile: path]];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[self addAndCopyFiles: [NSArray arrayWithObject: path] forKey: PCInterfaces];
|
|
|
|
[infoDict setObject: nibName forKey: @"NSMainNibFile"];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[self setProjectDictObject: nibName forKey: PCMainInterfaceFile notify: YES];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[mainNIBField setStringValue: nibName];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
- (void)clearMainNib: (id)sender
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[mainNIBField setStringValue: @""];
|
|
|
|
[infoDict setObject: @"" forKey: @"NSMainNibFile"];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[self setProjectDictObject: @"" forKey: PCMainInterfaceFile notify: YES];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Document Types
|
2008-12-17 07:04:14 +00:00
|
|
|
- (void)showDocTypesPanel: (id)sender
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[docTypesPanel makeKeyAndOrderFront: nil];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
- (void)setDocBasedApp: (id)sender
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
NSString *docBased = [projectDict objectForKey: PCDocumentBasedApp];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
|
|
|
if ([docBasedAppButton state] == NSOnState)
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[docTypeLabel setTextColor: [NSColor blackColor]];
|
|
|
|
[docTypeField setBackgroundColor: [NSColor whiteColor]];
|
|
|
|
[docTypeField setTextColor: [NSColor blackColor]];
|
|
|
|
[docTypeField setEditable: YES];
|
|
|
|
|
|
|
|
[docNameLabel setTextColor: [NSColor blackColor]];
|
|
|
|
[docNameField setBackgroundColor: [NSColor whiteColor]];
|
|
|
|
[docNameField setTextColor: [NSColor blackColor]];
|
|
|
|
[docNameField setEditable: YES];
|
|
|
|
|
|
|
|
[docRoleLabel setTextColor: [NSColor blackColor]];
|
|
|
|
[docRoleField setBackgroundColor: [NSColor whiteColor]];
|
|
|
|
[docRoleField setTextColor: [NSColor blackColor]];
|
|
|
|
[docRoleField setEditable: YES];
|
|
|
|
|
|
|
|
[docClassLabel setTextColor: [NSColor blackColor]];
|
|
|
|
[docClassField setBackgroundColor: [NSColor whiteColor]];
|
|
|
|
[docClassField setTextColor: [NSColor blackColor]];
|
|
|
|
[docClassField setEditable: YES];
|
|
|
|
|
|
|
|
[nameColumn setIdentifier: @"NSHumanReadableName"];
|
|
|
|
[[nameColumn headerCell] setStringValue: @"Name"];
|
|
|
|
[docTypesList addTableColumn: roleColumn];
|
|
|
|
[docTypesList addTableColumn: classColumn];
|
2006-12-26 11:00:33 +00:00
|
|
|
RELEASE(roleColumn);
|
|
|
|
RELEASE(classColumn);
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
if (![docBased isEqualToString: @"YES"])
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[self setProjectDictObject: @"YES"
|
|
|
|
forKey: PCDocumentBasedApp
|
|
|
|
notify: YES];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[docTypeLabel setTextColor: [NSColor darkGrayColor]];
|
|
|
|
[docTypeField setBackgroundColor: [NSColor lightGrayColor]];
|
|
|
|
[docTypeField setTextColor: [NSColor darkGrayColor]];
|
|
|
|
[docTypeField setEditable: NO];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[docNameLabel setTextColor: [NSColor darkGrayColor]];
|
|
|
|
[docNameField setBackgroundColor: [NSColor lightGrayColor]];
|
|
|
|
[docNameField setTextColor: [NSColor darkGrayColor]];
|
|
|
|
[docNameField setEditable: NO];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[docRoleLabel setTextColor: [NSColor darkGrayColor]];
|
|
|
|
[docRoleField setBackgroundColor: [NSColor lightGrayColor]];
|
|
|
|
[docRoleField setTextColor: [NSColor darkGrayColor]];
|
|
|
|
[docRoleField setEditable: NO];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[docClassLabel setTextColor: [NSColor darkGrayColor]];
|
|
|
|
[docClassField setBackgroundColor: [NSColor lightGrayColor]];
|
|
|
|
[docClassField setTextColor: [NSColor darkGrayColor]];
|
|
|
|
[docClassField setEditable: NO];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
|
|
|
// Columns
|
|
|
|
// [docTypesList removeTableColumn:nameColumn];
|
2008-12-17 07:04:14 +00:00
|
|
|
[nameColumn setIdentifier: @"NSIcon"];
|
|
|
|
[[nameColumn headerCell] setStringValue: @"Icon"];
|
2006-12-26 11:00:33 +00:00
|
|
|
RETAIN(roleColumn);
|
|
|
|
RETAIN(classColumn);
|
2008-12-17 07:04:14 +00:00
|
|
|
[docTypesList removeTableColumn: roleColumn];
|
|
|
|
[docTypesList removeTableColumn: classColumn];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
if (![docBased isEqualToString: @"NO"])
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[self setProjectDictObject: @"NO"
|
|
|
|
forKey: PCDocumentBasedApp
|
|
|
|
notify: YES];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
- (void)addDocType: (id)sender
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
int row;
|
2008-12-17 07:04:14 +00:00
|
|
|
NSMutableDictionary *entry = [NSMutableDictionary dictionaryWithCapacity: 6];
|
2006-12-26 11:00:33 +00:00
|
|
|
int selectedRow = [docTypesList selectedRow];
|
2008-12-17 07:04:14 +00:00
|
|
|
|
|
|
|
setOrRemove(entry, [docTypeField stringValue], @"NSName");
|
|
|
|
setOrRemove(entry, [docNameField stringValue], @"NSHumanReadableName");
|
|
|
|
setOrRemove(entry, [[docExtensionsField stringValue] componentsSeparatedByString: @","], @"NSUnixExtensions");
|
|
|
|
setOrRemove(entry, [docIconField stringValue], @"NSIcon");
|
|
|
|
setOrRemove(entry, [docRoleField stringValue], @"NSRole");
|
|
|
|
setOrRemove(entry, [docClassField stringValue], @"NSDocumentClass");
|
2006-12-26 11:00:33 +00:00
|
|
|
|
|
|
|
if (selectedRow >= 0 && [docTypesItems count] > 0)
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[docTypesItems insertObject: entry atIndex: selectedRow + 1];
|
2006-12-26 11:00:33 +00:00
|
|
|
row = selectedRow + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[docTypesItems addObject: entry];
|
2006-12-26 11:00:33 +00:00
|
|
|
row = [docTypesItems count] - 1;
|
|
|
|
}
|
|
|
|
[docTypesList reloadData];
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[docTypesList selectRow: row byExtendingSelection: NO];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[self fillFieldsForRow: row];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[self setProjectDictObject: docTypesItems
|
|
|
|
forKey: PCDocumentTypes
|
|
|
|
notify: YES];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
- (void)removeDocType: (id)sender
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
int selectedRow = [docTypesList selectedRow];
|
|
|
|
|
|
|
|
if (selectedRow >= 0)
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[docTypesItems removeObjectAtIndex: selectedRow];
|
2006-12-26 11:00:33 +00:00
|
|
|
[docTypesList reloadData];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (([docTypesList selectedRow] < 0) && ([docTypesItems count] > 0))
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[docTypesList selectRow: [docTypesItems count]-1
|
|
|
|
byExtendingSelection: NO];
|
|
|
|
[self fillFieldsForRow: [docTypesItems count]-1];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[self setProjectDictObject: docTypesItems
|
|
|
|
forKey: PCDocumentTypes
|
|
|
|
notify: YES];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
- (void)docFieldSet: (id)sender
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
NSMutableDictionary *object = nil;
|
|
|
|
|
|
|
|
NSLog(@"docFieldSet");
|
|
|
|
|
|
|
|
if (sender != docTypeField && sender != docNameField
|
2008-12-17 07:04:14 +00:00
|
|
|
&& sender != docIconField && sender != docExtensionsField
|
|
|
|
&& sender != docRoleField && sender != docClassField)
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ([docTypesItems count] <= 0)
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[self addDocType: addDocTypeButton];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
object = [[docTypesItems objectAtIndex: [docTypesList selectedRow]]
|
2006-12-26 11:00:33 +00:00
|
|
|
mutableCopy];
|
|
|
|
|
|
|
|
if (sender == docTypeField)
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
setOrRemove(object, [sender stringValue], @"NSName");
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
else if (sender == docNameField)
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
setOrRemove(object, [sender stringValue], @"NSHumanReadableName");
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
else if (sender == docIconField)
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
setOrRemove(object, [sender stringValue], @"NSIcon");
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
else if (sender == docExtensionsField)
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
setOrRemove(object,
|
|
|
|
[[sender stringValue] componentsSeparatedByString: @","],
|
|
|
|
@"NSUnixExtensions");
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
else if (sender == docRoleField)
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
setOrRemove(object, [sender stringValue], @"NSRole");
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
else if (sender == docClassField)
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
setOrRemove(object, [sender stringValue], @"NSDocumentClass");
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[docTypesItems replaceObjectAtIndex: [docTypesList selectedRow]
|
|
|
|
withObject: object];
|
2006-12-26 11:00:33 +00:00
|
|
|
[docTypesList reloadData];
|
|
|
|
[object release];
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// --- Document Types browser
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
- (int)numberOfRowsInTableView: (NSTableView *)aTableView
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
return [docTypesItems count];
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
- (id) tableView: (NSTableView *)aTableView
|
|
|
|
objectValueForTableColumn: (NSTableColumn *)aTableColumn
|
|
|
|
row: (int)rowIndex
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
NSDictionary *object = nil;
|
|
|
|
|
|
|
|
if (docTypesItems != nil || [docTypesItems count] > 0)
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
object = [docTypesItems objectAtIndex: rowIndex];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
|
|
|
if (aTableColumn == extensionsColumn)
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
return [[object objectForKey: @"NSUnixExtensions"]
|
|
|
|
componentsJoinedByString: @","];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
return [object objectForKey: [aTableColumn identifier]];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
- (void)tableView: (NSTableView *)aTableView
|
|
|
|
setObjectValue: anObject
|
|
|
|
forTableColumn: (NSTableColumn *)aTableColumn
|
|
|
|
row: (int)rowIndex
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
NSMutableDictionary *type = nil;
|
|
|
|
|
|
|
|
if (docTypesItems == nil || [docTypesItems count] <= 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
type = [docTypesItems objectAtIndex: rowIndex];
|
|
|
|
if ([[aTableColumn identifier] isEqualToString: @"NSUnixExtensions"])
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
setOrRemove(type, anObject, @"Extension");
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
2008-12-17 07:04:14 +00:00
|
|
|
else if ([[aTableColumn identifier] isEqualToString: @"NSIcon"])
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
setOrRemove(type, anObject, @"Icon");
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[self setProjectDictObject: docTypesItems
|
|
|
|
forKey: PCDocumentTypes
|
|
|
|
notify: YES];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
- (BOOL)tableView: (NSTableView *)aTableView shouldSelectRow: (int)rowIndex
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[self fillFieldsForRow: rowIndex];
|
2006-12-26 11:00:33 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
- (void)fillFieldsForRow: (int)rowIndex
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
NSMutableDictionary *type = nil;
|
2006-12-26 11:00:33 +00:00
|
|
|
int itemCount = [docTypesItems count];
|
|
|
|
|
|
|
|
if (itemCount <= 0 || rowIndex > itemCount || rowIndex < 0)
|
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[docTypeField setStringValue: @""];
|
|
|
|
[docNameField setStringValue: @""];
|
|
|
|
[docIconField setStringValue: @""];
|
|
|
|
[docExtensionsField setStringValue: @""];
|
2008-12-16 20:40:20 +00:00
|
|
|
[docRoleField setStringValue: @""];
|
2008-12-17 07:04:14 +00:00
|
|
|
[docClassField setStringValue: @""];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
type = [docTypesItems objectAtIndex: rowIndex];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[docTypeField setStringValue: cleanup(type, @"NSName")];
|
|
|
|
[docNameField setStringValue: cleanup(type, @"NSHumanReadableName")];
|
|
|
|
[docIconField setStringValue: cleanup(type, @"NSIcon")];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[docExtensionsField setStringValue: @""];
|
|
|
|
if ([[type objectForKey: @"NSUnixExtensions"] count] > 0)
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
[docExtensionsField setStringValue:
|
2008-12-17 07:04:14 +00:00
|
|
|
[[type objectForKey: @"NSUnixExtensions"]
|
|
|
|
componentsJoinedByString: @","]];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[docRoleField setStringValue: cleanup(type, @"NSRole")];
|
|
|
|
[docClassField setStringValue: cleanup(type, @"NSDocumentClass")];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// --- Notifications
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
- (void)updateInspectorValues: (NSNotification *)aNotif
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
// NSLog (@"PCAppProject: updateInspectorValues");
|
|
|
|
|
|
|
|
// Project Attributes view
|
2008-12-17 07:04:14 +00:00
|
|
|
[appTypeField selectItemWithTitle: [projectDict objectForKey: PCAppType]];
|
|
|
|
[appClassField setStringValue: [projectDict objectForKey: PCPrincipalClass]];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[appImageField setStringValue: [projectDict objectForKey: PCAppIcon]];
|
|
|
|
[helpFileField setStringValue: [projectDict objectForKey: PCHelpFile]];
|
|
|
|
[mainNIBField setStringValue:
|
|
|
|
[projectDict objectForKey: PCMainInterfaceFile]];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
docTypesItems = [projectDict objectForKey: PCDocumentTypes];
|
2006-12-26 11:00:33 +00:00
|
|
|
[docTypesList reloadData];
|
|
|
|
}
|
|
|
|
|
|
|
|
// TextFields (PCITextField subclass)
|
|
|
|
//
|
|
|
|
// NSTextField become first responder when user clicks on it and immediately
|
|
|
|
// lost first resonder status, so we can't catch when focus leaves textfield
|
|
|
|
// with resignFirstResponder: method overriding. Here we're using
|
|
|
|
// controlTextDidEndEditing (NSTextField's delegate method) to achieve this.
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
- (void)tfGetFocus: (NSNotification *)aNotif
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
id anObject = [aNotif object];
|
|
|
|
NSString *file = nil;
|
|
|
|
NSString *path = nil;
|
|
|
|
|
|
|
|
|
|
|
|
if (anObject != appImageField
|
2008-12-17 07:04:14 +00:00
|
|
|
&& anObject != helpFileField
|
|
|
|
&& anObject != mainNIBField)
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
// NSLog(@"tfGetFocus: not that textfield");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (anObject == appImageField)
|
|
|
|
{
|
|
|
|
file = [appImageField stringValue];
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
if (![file isEqualToString: @""])
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
path = [self dirForCategoryKey: PCImages];
|
|
|
|
path = [path stringByAppendingPathComponent: file];
|
|
|
|
[self setIconViewImage: [[NSImage alloc]
|
|
|
|
initWithContentsOfFile: path]];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
activeTextField = appImageField;
|
|
|
|
}
|
|
|
|
else if (anObject == helpFileField)
|
|
|
|
{
|
|
|
|
activeTextField = helpFileField;
|
|
|
|
}
|
|
|
|
else if (anObject == mainNIBField)
|
|
|
|
{
|
|
|
|
file = [mainNIBField stringValue];
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
if (![file isEqualToString: @""])
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
path = [projectPath stringByAppendingPathComponent: file];
|
|
|
|
[self setIconViewImage: [[NSWorkspace sharedWorkspace]
|
|
|
|
iconForFile: path]];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
activeTextField = mainNIBField;
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[setFieldButton setEnabled: YES];
|
|
|
|
[clearFieldButton setEnabled: YES];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
- (void)controlTextDidEndEditing: (NSNotification *)aNotification
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
NSControl *anObject = [aNotification object];
|
|
|
|
id target = [anObject target];
|
|
|
|
SEL action = [anObject action];
|
|
|
|
|
|
|
|
if (anObject == appImageField
|
2008-12-17 07:04:14 +00:00
|
|
|
|| anObject == helpFileField
|
|
|
|
|| anObject == mainNIBField)
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
|
|
|
activeTextField = nil;
|
2008-12-17 07:04:14 +00:00
|
|
|
[self setIconViewImage: nil];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
[setFieldButton setEnabled: NO];
|
|
|
|
[clearFieldButton setEnabled: NO];
|
2006-12-26 11:00:33 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-12-17 07:04:14 +00:00
|
|
|
if ([target respondsToSelector: action])
|
2006-12-26 11:00:33 +00:00
|
|
|
{
|
2008-12-17 07:04:14 +00:00
|
|
|
[target performSelector: action withObject: anObject];
|
2006-12-26 11:00:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|