2000-08-27 19:11:42 +00:00
/ *
2001-08-03 14:23:25 +00:00
GNUstep ProjectCenter - http : // www . gnustep . org
2000-08-27 19:11:42 +00:00
2001-08-03 14:23:25 +00:00
Copyright ( C ) 2001 Free Software Foundation
2000-08-27 19:11:42 +00:00
2001-08-03 14:23:25 +00:00
Author : Philippe C . D . Robert < phr @ 3 dkit . org >
2000-08-27 19:11:42 +00:00
2001-08-03 14:23:25 +00:00
This file is part of GNUstep .
2000-08-27 19:11:42 +00:00
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 .
$ Id $
* /
# import "PCProject.h"
2002-02-11 22:19:39 +00:00
# import "PCProject+ComponentHandling.h"
2000-08-27 19:11:42 +00:00
# import "ProjectCenter.h"
# import "PCProjectBuilder.h"
2002-01-27 13:55:07 +00:00
# import "PCSplitView.h"
2002-02-02 17:56:44 +00:00
# import "PCEditorController.h"
2000-08-27 19:11:42 +00:00
# if defined ( GNUSTEP )
# import < AppKit / IMLoading . h >
# endif
@ interface PCProject ( CreateUI )
- ( void ) _initUI ;
@ end
@ implementation PCProject ( CreateUI )
- ( void ) _initUI
{
NSView * _c _view ;
unsigned int style = NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask | NSResizableWindowMask ;
NSBrowser * browser ;
2002-02-03 19:31:28 +00:00
NSRect rect ;
2000-08-27 19:11:42 +00:00
NSMatrix * matrix ;
NSButtonCell * buttonCell = [ [ [ NSButtonCell alloc ] init ] autorelease ] ;
id textField ;
2002-02-03 19:31:28 +00:00
id textView ;
id scrollView ;
2000-08-27 19:11:42 +00:00
id button ;
2002-01-27 13:55:07 +00:00
PCSplitView * split ;
2000-08-27 19:11:42 +00:00
browserController = [ [ PCBrowserController alloc ] init ] ;
/ *
* Project Window
*
* /
2002-02-03 19:31:28 +00:00
rect = NSMakeRect ( 100 , 100 , 560 , 440 ) ;
projectWindow = [ [ NSWindow alloc ] initWithContentRect : rect
2000-08-27 19:11:42 +00:00
styleMask : style
backing : NSBackingStoreBuffered
2000-10-27 17:15:34 +00:00
defer : YES ] ;
2000-08-27 19:11:42 +00:00
[ projectWindow setDelegate : self ] ;
2000-10-29 20:15:39 +00:00
[ projectWindow setMinSize : NSMakeSize ( 560 , 448 ) ] ;
2000-08-27 19:11:42 +00:00
2002-01-27 13:32:46 +00:00
browser = [ [ NSBrowser alloc ] initWithFrame : NSMakeRect ( -1 , 251 , 562 , 128 ) ] ;
2000-08-27 19:11:42 +00:00
[ browser setDelegate : browserController ] ;
[ browser setMaxVisibleColumns : 3 ] ;
[ browser setAllowsMultipleSelection : NO ] ;
2000-10-29 20:15:39 +00:00
[ browser setAutoresizingMask : NSViewWidthSizable | NSViewMinYMargin ] ;
2000-08-27 19:11:42 +00:00
[ browserController setBrowser : browser ] ;
2002-02-03 19:31:28 +00:00
rect . size . height - = 64 ;
2000-08-27 19:11:42 +00:00
[ browserController setProject : self ] ;
2001-01-07 12:12:17 +00:00
2002-01-27 13:32:46 +00:00
box = [ [ NSBox alloc ] initWithFrame : NSMakeRect ( -1 , -1 , 562 , 252 ) ] ;
2000-10-29 20:15:39 +00:00
[ box setTitlePosition : NSNoTitle ] ;
[ box setBorderType : NSNoBorder ] ;
2002-01-27 13:32:46 +00:00
[ box setContentViewMargins : NSMakeSize ( 0.0 , 0.0 ) ] ;
2000-10-29 20:15:39 +00:00
[ box setAutoresizingMask : NSViewWidthSizable | NSViewHeightSizable ] ;
2000-08-27 19:11:42 +00:00
2002-02-03 19:31:28 +00:00
textField = [ [ NSTextField alloc ] initWithFrame : NSMakeRect ( 16 , 200 , 500 , 21 ) ] ;
2000-11-02 10:21:03 +00:00
[ textField setAlignment : NSLeftTextAlignment ] ;
[ textField setBordered : NO ] ;
[ textField setEditable : NO ] ;
[ textField setBezeled : NO ] ;
[ textField setDrawsBackground : NO ] ;
2002-02-03 19:31:28 +00:00
[ textField setStringValue : @ "Welcome to ProjectCenter.app" ] ;
2001-01-14 15:53:46 +00:00
[ box addSubview : textField ] ;
RELEASE ( textField ) ;
2000-11-02 10:21:03 +00:00
2002-02-03 19:31:28 +00:00
rect = [ [ projectWindow contentView ] frame ] ;
rect . size . height - = 76 ;
rect . size . width - = 16 ;
rect . origin . x + = 8 ;
split = [ [ PCSplitView alloc ] initWithFrame : rect ] ;
2002-01-27 13:32:46 +00:00
[ split setAutoresizingMask : ( NSViewWidthSizable | NSViewHeightSizable ) ] ;
2000-08-27 19:11:42 +00:00
_c _view = [ projectWindow contentView ] ;
2002-01-27 13:32:46 +00:00
[ split addSubview : browser ] ;
[ split addSubview : box ] ;
[ split adjustSubviews ] ;
[ _c _view addSubview : split ] ;
RELEASE ( split ) ;
2000-08-27 19:11:42 +00:00
2001-01-14 15:53:46 +00:00
RELEASE ( browser ) ;
2000-09-22 10:33:12 +00:00
/ *
* Left button matrix
* /
2002-02-11 22:19:39 +00:00
rect = NSMakeRect ( 8 , 372 , 300 , 60 ) ;
2002-02-03 19:31:28 +00:00
matrix = [ [ NSMatrix alloc ] initWithFrame : rect
2001-01-14 15:53:46 +00:00
mode : NSHighlightModeMatrix
prototype : buttonCell
numberOfRows : 1
2002-02-11 22:19:39 +00:00
numberOfColumns : 5 ] ;
2000-09-19 15:39:55 +00:00
[ matrix sizeToCells ] ;
2000-10-29 20:15:39 +00:00
[ matrix setTarget : self ] ;
[ matrix setAction : @ selector ( topButtonsPressed : ) ] ;
2000-08-27 19:11:42 +00:00
[ matrix setSelectionByRect : YES ] ;
[ matrix setAutoresizingMask : ( NSViewMaxXMargin | NSViewMinYMargin ) ] ;
[ _c _view addSubview : matrix ] ;
2001-01-14 15:53:46 +00:00
RELEASE ( matrix ) ;
2000-08-27 19:11:42 +00:00
button = [ matrix cellAtRow : 0 column : 0 ] ;
2000-10-29 20:15:39 +00:00
[ button setTag : 0 ] ;
2002-01-27 13:32:46 +00:00
[ button setImagePosition : NSImageAbove ] ;
[ button setTitle : @ "Build" ] ;
2000-09-17 12:13:10 +00:00
[ button setImage : IMAGE ( @ "ProjectCentre_build" ) ] ;
2000-08-27 19:11:42 +00:00
[ button setButtonType : NSMomentaryPushButton ] ;
button = [ matrix cellAtRow : 0 column : 1 ] ;
2000-10-29 20:15:39 +00:00
[ button setTag : 1 ] ;
2002-01-27 13:32:46 +00:00
[ button setImagePosition : NSImageAbove ] ;
[ button setTitle : @ "Settings" ] ;
2000-09-17 12:13:10 +00:00
[ button setImage : IMAGE ( @ "ProjectCentre_settings.tiff" ) ] ;
2000-08-27 19:11:42 +00:00
[ button setButtonType : NSMomentaryPushButton ] ;
button = [ matrix cellAtRow : 0 column : 2 ] ;
2000-10-29 20:15:39 +00:00
[ button setTag : 2 ] ;
2002-01-27 13:32:46 +00:00
[ button setImagePosition : NSImageAbove ] ;
[ button setTitle : @ "Options" ] ;
2000-09-17 12:13:10 +00:00
[ button setImage : IMAGE ( @ "ProjectCentre_prefs.tiff" ) ] ;
2000-08-27 19:11:42 +00:00
[ button setButtonType : NSMomentaryPushButton ] ;
2000-09-22 10:33:12 +00:00
button = [ matrix cellAtRow : 0 column : 3 ] ;
2000-10-29 20:15:39 +00:00
[ button setTag : 3 ] ;
2002-01-27 13:32:46 +00:00
[ button setImagePosition : NSImageAbove ] ;
[ button setTitle : @ "Run" ] ;
2000-09-17 12:13:10 +00:00
[ button setImage : IMAGE ( @ "ProjectCentre_run.tiff" ) ] ;
2000-08-27 19:11:42 +00:00
[ button setButtonType : NSMomentaryPushButton ] ;
2002-02-11 22:19:39 +00:00
button = [ matrix cellAtRow : 0 column : 4 ] ;
[ button setTag : 4 ] ;
[ button setImagePosition : NSImageAbove ] ;
[ button setTitle : @ "Editor" ] ;
[ button setImage : IMAGE ( @ "ProjectCentre_files.tiff" ) ] ;
[ button setButtonType : NSMomentaryPushButton ] ;
2000-08-27 19:11:42 +00:00
/ *
2000-09-17 14:40:56 +00:00
* Build Options Panel
2000-08-27 19:11:42 +00:00
*
* /
2002-02-03 19:31:28 +00:00
rect = NSMakeRect ( 100 , 100 , 272 , 80 ) ;
2000-10-29 20:15:39 +00:00
style = NSTitledWindowMask | NSClosableWindowMask ;
2002-02-03 19:31:28 +00:00
buildTargetPanel = [ [ NSWindow alloc ] initWithContentRect : rect
2000-10-29 20:15:39 +00:00
styleMask : style
backing : NSBackingStoreBuffered
defer : YES ] ;
2000-09-17 12:13:10 +00:00
[ buildTargetPanel setDelegate : self ] ;
2000-08-27 19:11:42 +00:00
[ buildTargetPanel setReleasedWhenClosed : NO ] ;
[ buildTargetPanel setTitle : @ "Build Options" ] ;
_c _view = [ buildTargetPanel contentView ] ;
// Host
2000-09-17 14:40:56 +00:00
textField = [ [ NSTextField alloc ] initWithFrame : NSMakeRect ( 16 , 24 , 56 , 21 ) ] ;
2000-08-27 19:11:42 +00:00
[ textField setAlignment : NSRightTextAlignment ] ;
[ textField setBordered : NO ] ;
[ textField setEditable : NO ] ;
[ textField setBezeled : NO ] ;
[ textField setDrawsBackground : NO ] ;
[ textField setStringValue : @ "Host:" ] ;
2001-01-14 15:53:46 +00:00
[ _c _view addSubview : textField ] ;
RELEASE ( textField ) ;
2000-08-27 19:11:42 +00:00
// Host message
2000-09-17 14:40:56 +00:00
buildTargetHostField = [ [ NSTextField alloc ] initWithFrame : NSMakeRect ( 72 , 24 , 184 , 21 ) ] ;
2000-09-17 12:13:10 +00:00
[ buildTargetHostField setAlignment : NSLeftTextAlignment ] ;
[ buildTargetHostField setBordered : NO ] ;
[ buildTargetHostField setEditable : YES ] ;
[ buildTargetHostField setBezeled : YES ] ;
[ buildTargetHostField setDrawsBackground : YES ] ;
[ buildTargetHostField setStringValue : @ "localhost" ] ;
[ buildTargetHostField setDelegate : self ] ;
[ buildTargetHostField setTarget : self ] ;
[ buildTargetHostField setAction : @ selector ( setHost : ) ] ;
2001-01-14 15:53:46 +00:00
[ _c _view addSubview : buildTargetHostField ] ;
2000-08-27 19:11:42 +00:00
// Args
2000-09-17 14:40:56 +00:00
textField = [ [ NSTextField alloc ] initWithFrame : NSMakeRect ( 12 , 44 , 60 , 21 ) ] ;
2000-08-27 19:11:42 +00:00
[ textField setAlignment : NSRightTextAlignment ] ;
[ textField setBordered : NO ] ;
[ textField setEditable : NO ] ;
[ textField setBezeled : NO ] ;
[ textField setDrawsBackground : NO ] ;
[ textField setStringValue : @ "Arguments:" ] ;
2001-01-14 15:53:46 +00:00
[ _c _view addSubview : textField ] ;
RELEASE ( textField ) ;
2000-08-27 19:11:42 +00:00
// Args message
2000-09-17 14:40:56 +00:00
buildTargetArgsField = [ [ NSTextField alloc ] initWithFrame : NSMakeRect ( 72 , 44 , 184 , 21 ) ] ;
2000-09-17 12:13:10 +00:00
[ buildTargetArgsField setAlignment : NSLeftTextAlignment ] ;
[ buildTargetArgsField setBordered : NO ] ;
[ buildTargetArgsField setEditable : YES ] ;
[ buildTargetArgsField setBezeled : YES ] ;
[ buildTargetArgsField setDrawsBackground : YES ] ;
[ buildTargetArgsField setStringValue : @ "" ] ;
[ buildTargetArgsField setDelegate : self ] ;
[ buildTargetArgsField setTarget : self ] ;
[ buildTargetArgsField setAction : @ selector ( setArguments : ) ] ;
2001-01-14 15:53:46 +00:00
[ _c _view addSubview : buildTargetArgsField ] ;
2000-08-27 19:11:42 +00:00
2000-10-15 18:24:09 +00:00
/ *
* Model the standard inspector UI
*
* /
projectAttributeInspectorView = [ [ NSBox alloc ] init ] ;
[ projectAttributeInspectorView setFrame : NSMakeRect ( -2 , -2 , 284 , 334 ) ] ;
[ projectAttributeInspectorView setTitlePosition : NSNoTitle ] ;
[ projectAttributeInspectorView setBorderType : NSNoBorder ] ;
[ projectAttributeInspectorView setAutoresizingMask : ( NSViewWidthSizable | NSViewHeightSizable ) ] ;
textField = [ [ NSTextField alloc ] initWithFrame : NSMakeRect ( 16 , 280 , 64 , 21 ) ] ;
[ textField setAlignment : NSRightTextAlignment ] ;
[ textField setBordered : NO ] ;
[ textField setEditable : NO ] ;
[ textField setBezeled : NO ] ;
[ textField setDrawsBackground : NO ] ;
[ textField setStringValue : @ "Install in:" ] ;
2001-01-14 15:53:46 +00:00
[ projectAttributeInspectorView addSubview : textField ] ;
RELEASE ( textField ) ;
2000-10-15 18:24:09 +00:00
installPathField = [ [ NSTextField alloc ] initWithFrame : NSMakeRect ( 84 , 280 , 176 , 21 ) ] ;
[ installPathField setAlignment : NSLeftTextAlignment ] ;
[ installPathField setBordered : YES ] ;
[ installPathField setEditable : YES ] ;
[ installPathField setBezeled : YES ] ;
[ installPathField setDrawsBackground : YES ] ;
[ installPathField setStringValue : @ "" ] ;
2002-01-02 16:05:02 +00:00
[ installPathField setAction : @ selector ( changeCommonProjectEntry : ) ] ;
[ installPathField setTarget : self ] ;
2000-10-15 18:24:09 +00:00
[ projectAttributeInspectorView addSubview : installPathField ] ;
textField = [ [ NSTextField alloc ] initWithFrame : NSMakeRect ( 16 , 256 , 64 , 21 ) ] ;
[ textField setAlignment : NSRightTextAlignment ] ;
[ textField setBordered : NO ] ;
[ textField setEditable : NO ] ;
[ textField setBezeled : NO ] ;
[ textField setDrawsBackground : NO ] ;
[ textField setStringValue : @ "Build tool:" ] ;
2001-01-14 15:53:46 +00:00
[ projectAttributeInspectorView addSubview : textField ] ;
RELEASE ( textField ) ;
2000-10-15 18:24:09 +00:00
toolField = [ [ NSTextField alloc ] initWithFrame : NSMakeRect ( 84 , 256 , 176 , 21 ) ] ;
[ toolField setAlignment : NSLeftTextAlignment ] ;
[ toolField setBordered : YES ] ;
2002-01-02 17:43:11 +00:00
[ toolField setEditable : YES ] ;
2000-10-15 18:24:09 +00:00
[ toolField setBezeled : YES ] ;
[ toolField setDrawsBackground : YES ] ;
[ toolField setStringValue : @ "" ] ;
2002-01-02 16:05:02 +00:00
[ toolField setAction : @ selector ( changeCommonProjectEntry : ) ] ;
[ toolField setTarget : self ] ;
2000-10-15 18:24:09 +00:00
[ projectAttributeInspectorView addSubview : toolField ] ;
textField = [ [ NSTextField alloc ] initWithFrame : NSMakeRect ( 16 , 232 , 64 , 21 ) ] ;
[ textField setAlignment : NSRightTextAlignment ] ;
[ textField setBordered : NO ] ;
[ textField setEditable : NO ] ;
[ textField setBezeled : NO ] ;
[ textField setDrawsBackground : NO ] ;
[ textField setStringValue : @ "CC options:" ] ;
2001-01-14 15:53:46 +00:00
[ projectAttributeInspectorView addSubview : textField ] ;
RELEASE ( textField ) ;
2000-10-15 18:24:09 +00:00
ccOptField = [ [ NSTextField alloc ] initWithFrame : NSMakeRect ( 84 , 232 , 176 , 21 ) ] ;
[ ccOptField setAlignment : NSLeftTextAlignment ] ;
[ ccOptField setBordered : YES ] ;
[ ccOptField setEditable : YES ] ;
[ ccOptField setBezeled : YES ] ;
[ ccOptField setDrawsBackground : YES ] ;
[ ccOptField setStringValue : @ "" ] ;
2002-01-02 16:05:02 +00:00
[ ccOptField setAction : @ selector ( changeCommonProjectEntry : ) ] ;
[ ccOptField setTarget : self ] ;
2000-10-15 18:24:09 +00:00
[ projectAttributeInspectorView addSubview : ccOptField ] ;
textField = [ [ NSTextField alloc ] initWithFrame : NSMakeRect ( 16 , 204 , 64 , 21 ) ] ;
[ textField setAlignment : NSRightTextAlignment ] ;
[ textField setBordered : NO ] ;
[ textField setEditable : NO ] ;
[ textField setBezeled : NO ] ;
[ textField setDrawsBackground : NO ] ;
[ textField setStringValue : @ "LD options:" ] ;
2001-01-14 15:53:46 +00:00
[ projectAttributeInspectorView addSubview : textField ] ;
RELEASE ( textField ) ;
2000-10-15 18:24:09 +00:00
ldOptField = [ [ NSTextField alloc ] initWithFrame : NSMakeRect ( 84 , 204 , 176 , 21 ) ] ;
[ ldOptField setAlignment : NSLeftTextAlignment ] ;
[ ldOptField setBordered : YES ] ;
2002-01-02 16:05:02 +00:00
[ ldOptField setEditable : NO ] ;
2000-10-15 18:24:09 +00:00
[ ldOptField setBezeled : YES ] ;
[ ldOptField setDrawsBackground : YES ] ;
[ ldOptField setStringValue : @ "" ] ;
2002-01-02 16:05:02 +00:00
[ ldOptField setAction : @ selector ( changeCommonProjectEntry : ) ] ;
[ ldOptField setTarget : self ] ;
2000-10-15 18:24:09 +00:00
[ projectAttributeInspectorView addSubview : ldOptField ] ;
2000-11-10 18:27:15 +00:00
/ *
* Project View
*
* /
2000-10-15 18:24:09 +00:00
projectProjectInspectorView = [ [ NSBox alloc ] init ] ;
[ projectProjectInspectorView setFrame : NSMakeRect ( -2 , -2 , 284 , 334 ) ] ;
[ projectProjectInspectorView setTitlePosition : NSNoTitle ] ;
[ projectProjectInspectorView setBorderType : NSNoBorder ] ;
[ projectProjectInspectorView setAutoresizingMask : ( NSViewWidthSizable | NSViewHeightSizable ) ] ;
textField = [ [ NSTextField alloc ] initWithFrame : NSMakeRect ( 16 , 280 , 64 , 21 ) ] ;
[ textField setAlignment : NSRightTextAlignment ] ;
[ textField setBordered : NO ] ;
[ textField setEditable : NO ] ;
[ textField setBezeled : NO ] ;
[ textField setDrawsBackground : NO ] ;
2000-10-20 15:18:43 +00:00
[ textField setStringValue : @ "Type:" ] ;
2001-01-14 15:53:46 +00:00
[ projectProjectInspectorView addSubview : textField ] ;
RELEASE ( textField ) ;
2000-10-15 18:24:09 +00:00
2000-11-10 18:27:15 +00:00
projectTypeField = [ [ NSTextField alloc ] initWithFrame : NSMakeRect ( 84 , 280 , 176 , 21 ) ] ;
2000-10-15 18:24:09 +00:00
[ projectTypeField setAlignment : NSLeftTextAlignment ] ;
[ projectTypeField setBordered : NO ] ;
[ projectTypeField setEditable : NO ] ;
[ projectTypeField setBezeled : NO ] ;
[ projectTypeField setDrawsBackground : NO ] ;
[ projectTypeField setStringValue : @ "" ] ;
[ projectProjectInspectorView addSubview : projectTypeField ] ;
projectFileInspectorView = [ [ NSBox alloc ] init ] ;
[ projectFileInspectorView setFrame : NSMakeRect ( -2 , -2 , 284 , 334 ) ] ;
[ projectFileInspectorView setTitlePosition : NSNoTitle ] ;
[ projectFileInspectorView setBorderType : NSNoBorder ] ;
[ projectFileInspectorView setAutoresizingMask : ( NSViewWidthSizable | NSViewHeightSizable ) ] ;
textField = [ [ NSTextField alloc ] initWithFrame : NSMakeRect ( 16 , 280 , 64 , 21 ) ] ;
[ textField setAlignment : NSRightTextAlignment ] ;
[ textField setBordered : NO ] ;
[ textField setEditable : NO ] ;
[ textField setBezeled : NO ] ;
[ textField setDrawsBackground : NO ] ;
[ textField setStringValue : @ "Filename:" ] ;
2001-01-14 15:53:46 +00:00
[ projectFileInspectorView addSubview : textField ] ;
RELEASE ( textField ) ;
2000-10-15 18:24:09 +00:00
fileNameField = [ [ NSTextField alloc ] initWithFrame : NSMakeRect ( 84 , 280 , 176 , 21 ) ] ;
[ fileNameField setAlignment : NSLeftTextAlignment ] ;
[ fileNameField setBordered : NO ] ;
[ fileNameField setEditable : NO ] ;
[ fileNameField setBezeled : NO ] ;
[ fileNameField setDrawsBackground : NO ] ;
[ fileNameField setStringValue : @ "" ] ;
[ projectFileInspectorView addSubview : fileNameField ] ;
changeFileNameButton = [ [ NSButton alloc ] initWithFrame : NSMakeRect ( 84 , 240 , 104 , 21 ) ] ;
[ changeFileNameButton setTitle : @ "Rename..." ] ;
[ changeFileNameButton setTarget : self ] ;
[ changeFileNameButton setAction : @ selector ( renameFile : ) ] ;
[ projectFileInspectorView addSubview : changeFileNameButton ] ;
/ *
*
* /
2000-08-27 19:11:42 +00:00
[ browser loadColumnZero ] ;
}
@ end
@ implementation PCProject
2002-02-02 17:56:44 +00:00
// === === === === === === === === === === === === === === === === === === === === === === === === === ===
2000-08-27 19:11:42 +00:00
// === = Init and free
2002-02-02 17:56:44 +00:00
// === === === === === === === === === === === === === === === === === === === === === === === === === ===
2000-08-27 19:11:42 +00:00
- ( id ) init
{
2002-02-02 17:56:44 +00:00
if ( ( self = [ super init ] ) )
{
2002-02-11 22:19:39 +00:00
editorIsActive = NO ;
2000-09-17 12:13:10 +00:00
buildOptions = [ [ NSMutableDictionary alloc ] init ] ;
2000-08-27 19:11:42 +00:00
[ self _initUI ] ;
2002-02-02 17:56:44 +00:00
editorController = [ [ PCEditorController alloc ] init ] ;
[ editorController setProject : self ] ;
2000-08-27 19:11:42 +00:00
}
return self ;
}
- ( id ) initWithProjectDictionary : ( NSDictionary * ) dict path : ( NSString * ) path ;
{
NSAssert ( dict , @ "No valid project dictionary!" ) ;
2002-02-02 17:56:44 +00:00
if ( ( self = [ self init ] ) )
{
2000-08-27 19:11:42 +00:00
if ( [ [ path lastPathComponent ] isEqualToString : @ "PC.project" ] ) {
projectPath = [ [ path stringByDeletingLastPathComponent ] copy ] ;
}
else {
projectPath = [ path copy ] ;
}
if ( ! [ self assignProjectDict : dict ] ) {
NSLog ( @ "<%@ %x>: could not load the project..." , [ self class ] , self ) ;
[ self autorelease ] ;
return nil ;
}
}
return self ;
}
- ( void ) dealloc
{
2001-01-14 15:53:46 +00:00
RELEASE ( projectName ) ;
RELEASE ( projectPath ) ;
RELEASE ( projectDict ) ;
RELEASE ( projectManager ) ;
RELEASE ( projectBuilder ) ;
RELEASE ( projectDebugger ) ;
2000-10-15 18:24:09 +00:00
2001-01-14 15:53:46 +00:00
RELEASE ( browserController ) ;
RELEASE ( projectWindow ) ;
RELEASE ( buildTargetPanel ) ;
RELEASE ( buildTargetHostField ) ;
RELEASE ( buildTargetArgsField ) ;
2000-10-15 18:24:09 +00:00
2001-01-14 15:53:46 +00:00
RELEASE ( buildOptions ) ;
2000-10-15 18:24:09 +00:00
2001-01-14 15:53:46 +00:00
RELEASE ( projectAttributeInspectorView ) ;
RELEASE ( installPathField ) ;
RELEASE ( toolField ) ;
RELEASE ( ccOptField ) ;
RELEASE ( ldOptField ) ;
RELEASE ( projectProjectInspectorView ) ;
RELEASE ( projectTypeField ) ;
RELEASE ( projectFileInspectorView ) ;
RELEASE ( fileNameField ) ;
RELEASE ( changeFileNameButton ) ;
2000-10-15 18:24:09 +00:00
2001-01-14 15:53:46 +00:00
RELEASE ( box ) ;
2002-02-02 17:56:44 +00:00
RELEASE ( editorController ) ;
2000-10-29 20:15:39 +00:00
2000-10-15 18:24:09 +00:00
[ super dealloc ] ;
2000-08-27 19:11:42 +00:00
}
2002-02-02 17:56:44 +00:00
// === === === === === === === === === === === === === === === === === === === === === === === === === ===
2000-08-27 19:11:42 +00:00
// === = Accessor methods
2002-02-02 17:56:44 +00:00
// === === === === === === === === === === === === === === === === === === === === === === === === === ===
2000-08-27 19:11:42 +00:00
- ( id ) browserController
{
return browserController ;
}
2000-09-17 12:13:10 +00:00
- ( NSString * ) selectedRootCategory
{
2001-01-13 20:46:59 +00:00
NSString * _path = [ browserController pathOfSelectedFile ] ;
return [ self projectKeyForKeyPath : _path ] ;
2000-09-17 12:13:10 +00:00
}
- ( NSArray * ) fileExtensionsForCategory : ( NSString * ) key
{
if ( [ key isEqualToString : PCGModels ] ) {
return [ NSArray arrayWithObjects : @ "gmodel" , @ "gorm" , nil ] ;
}
else if ( [ key isEqualToString : PCClasses ] ) {
return [ NSArray arrayWithObjects : @ "m" , nil ] ;
}
else if ( [ key isEqualToString : PCHeaders ] ) {
return [ NSArray arrayWithObjects : @ "h" , nil ] ;
}
else if ( [ key isEqualToString : PCOtherSources ] ) {
2002-01-02 16:05:02 +00:00
return [ NSArray arrayWithObjects : @ "c" , @ "C" , @ "M" , nil ] ;
2000-09-17 12:13:10 +00:00
}
else if ( [ key isEqualToString : PCLibraries ] ) {
return [ NSArray arrayWithObjects : @ "so" , @ "a" , @ "lib" , nil ] ;
}
else if ( [ key isEqualToString : PCSubprojects ] ) {
return [ NSArray arrayWithObjects : @ "subproj" , nil ] ;
}
else if ( [ key isEqualToString : PCImages ] ) {
2000-10-26 09:12:24 +00:00
return [ NSImage imageFileTypes ] ;
2000-09-17 12:13:10 +00:00
}
return nil ;
}
2000-08-27 19:11:42 +00:00
- ( void ) setProjectName : ( NSString * ) aName
{
2002-01-02 16:05:02 +00:00
AUTORELEASE ( projectName ) ;
2000-08-27 19:11:42 +00:00
projectName = [ aName copy ] ;
}
- ( NSString * ) projectName
{
return projectName ;
}
- ( NSWindow * ) projectWindow
{
2002-01-02 16:05:02 +00:00
return projectWindow ;
2000-08-27 19:11:42 +00:00
}
- ( Class ) principalClass
{
return [ self class ] ;
}
2002-02-02 17:56:44 +00:00
- ( PCEditorController * ) editorController
{
return editorController ;
}
// === === === === === === === === === === === === === === === === === === === === === === === === === ===
2000-08-27 19:11:42 +00:00
// === = Delegate and manager
2002-02-02 17:56:44 +00:00
// === === === === === === === === === === === === === === === === === === === === === === === === === ===
2000-08-27 19:11:42 +00:00
- ( id ) delegate
{
2002-01-02 16:05:02 +00:00
return delegate ;
2000-08-27 19:11:42 +00:00
}
- ( void ) setDelegate : ( id ) aDelegate
{
2002-01-02 16:05:02 +00:00
delegate = aDelegate ;
2000-08-27 19:11:42 +00:00
}
2002-02-02 17:56:44 +00:00
- ( void ) setProjectBuilder : ( id < ProjectBuilder , NSObject > ) aBuilder
2000-08-27 19:11:42 +00:00
{
2002-01-02 16:05:02 +00:00
AUTORELEASE ( projectManager ) ;
projectManager = RETAIN ( aBuilder ) ;
2000-08-27 19:11:42 +00:00
}
- ( id < ProjectBuilder > ) projectBuilder
{
2002-01-02 16:05:02 +00:00
return projectManager ;
2000-08-27 19:11:42 +00:00
}
2002-02-02 17:56:44 +00:00
// === === === === === === === === === === === === === === === === === === === === === === === === === ===
2000-08-27 19:11:42 +00:00
// === = To be overriden
2002-02-02 17:56:44 +00:00
// === === === === === === === === === === === === === === === === === === === === === === === === === ===
2000-08-27 19:11:42 +00:00
2002-01-01 17:27:41 +00:00
- ( Class ) builderClass
{
return Nil ;
}
2000-08-27 19:11:42 +00:00
- ( BOOL ) writeMakefile
{
2001-12-29 14:09:39 +00:00
NSString * mf = [ projectPath stringByAppendingPathComponent : @ "GNUmakefile" ] ;
NSString * bu = [ projectPath stringByAppendingPathComponent : @ "GNUmakefile~" ] ;
NSFileManager * fm = [ NSFileManager defaultManager ] ;
2001-12-29 14:41:43 +00:00
if ( [ fm isReadableFileAtPath : mf ] ) {
if ( [ fm isWritableFileAtPath : bu ] ) {
[ fm removeFileAtPath : bu handler : nil ] ;
}
if ( ! [ fm copyPath : mf toPath : bu handler : nil ] ) {
NSRunAlertPanel ( @ "Attention!" ,
@ "Could not keep a backup of the GNUMakefile!" ,
@ "OK" , nil , nil ) ;
}
2001-12-29 14:09:39 +00:00
}
2002-01-02 16:05:02 +00:00
return YES ;
2000-08-27 19:11:42 +00:00
}
- ( NSArray * ) sourceFileKeys
{
return nil ;
}
- ( NSArray * ) resourceFileKeys
{
return nil ;
}
- ( NSArray * ) otherKeys
{
return nil ;
}
- ( NSArray * ) buildTargets
{
return nil ;
}
- ( NSString * ) projectDescription
{
return @ "Abstract PCProject class!" ;
}
2000-11-04 13:20:40 +00:00
- ( BOOL ) isExecutable
{
return NO ;
}
2000-11-10 18:27:15 +00:00
// === === === === === === === === === === === === === === === === === === === === === === === === === = =
// === = File Handling
// === === === === === === === === === === === === === === === === === === === === === === === === === = =
2000-08-27 19:11:42 +00:00
2000-10-15 18:24:09 +00:00
- ( void ) browserDidSelectFileNamed : ( NSString * ) fileName
{
2002-02-11 22:19:39 +00:00
NSString * p = [ [ self projectPath ] stringByAppendingPathComponent : fileName ] ;
PCEditor * e ;
// Set the name in the inspector
2002-01-02 16:05:02 +00:00
[ fileNameField setStringValue : fileName ] ;
2002-02-11 22:19:39 +00:00
// Show the file in the internal editor !
e = [ editorController editorForFile : p ] ;
[ e showInProjectEditor : projectEditor ] ;
[ self showEditorView : self ] ;
[ projectWindow makeFirstResponder : [ projectEditor editorView ] ] ;
2000-10-15 18:24:09 +00:00
}
2000-08-27 19:11:42 +00:00
- ( BOOL ) doesAcceptFile : ( NSString * ) file forKey : ( NSString * ) type
{
if ( [ [ projectDict allKeys ] containsObject : type ] ) {
NSArray * files = [ projectDict objectForKey : type ] ;
if ( ! [ files containsObject : file ] ) {
return YES ;
}
}
return NO ;
}
- ( void ) addFile : ( NSString * ) file forKey : ( NSString * ) type
{
2002-01-02 16:05:02 +00:00
[ self addFile : file forKey : type copy : NO ] ;
2001-01-06 16:26:01 +00:00
}
2000-08-27 19:11:42 +00:00
2001-01-06 16:26:01 +00:00
- ( void ) addFile : ( NSString * ) file forKey : ( NSString * ) type copy : ( BOOL ) yn
{
2001-12-29 14:09:39 +00:00
NSArray * types = [ projectDict objectForKey : type ] ;
NSMutableArray * files = [ NSMutableArray arrayWithArray : types ] ;
NSString * lpc = [ file lastPathComponent ] ;
NSMutableString * newFile = [ NSMutableString stringWithString : lpc ] ;
2001-01-06 16:26:01 +00:00
2001-12-29 14:09:39 +00:00
if ( [ type isEqualToString : PCLibraries ] ) {
[ newFile deleteCharactersInRange : NSMakeRange ( 0 , 3 ) ] ;
2002-02-02 17:56:44 +00:00
newFile = ( NSMutableString * ) [ newFile stringByDeletingPathExtension ] ;
2001-12-29 14:09:39 +00:00
}
2001-01-06 16:26:01 +00:00
2001-12-29 14:09:39 +00:00
if ( [ files containsObject : newFile ] ) {
NSRunAlertPanel ( @ "Attention!" ,
@ "The file %@ is already part of this project!" ,
@ "OK" , nil , nil , newFile ) ;
return ;
}
2001-01-06 16:26:01 +00:00
2000-11-10 18:27:15 +00:00
# ifdef DEBUG
2001-12-29 14:09:39 +00:00
NSLog ( @ "<%@ %x>: adding file %@ for key %@" , [ self class ] , self , newFile , type ) ;
# endif // DEBUG
2001-01-06 16:26:01 +00:00
2001-12-29 14:09:39 +00:00
// Add the new file
[ files addObject : newFile ] ;
[ projectDict setObject : files forKey : type ] ;
2002-01-02 16:05:02 +00:00
[ projectWindow setDocumentEdited : YES ] ;
2001-01-06 16:26:01 +00:00
2001-12-29 14:09:39 +00:00
if ( yn ) {
NSFileManager * manager = [ NSFileManager defaultManager ] ;
NSString * destination = [ [ self projectPath ] stringByAppendingPathComponent : newFile ] ;
2000-08-27 19:11:42 +00:00
2001-12-29 14:09:39 +00:00
if ( ! [ manager copyPath : file toPath : destination handler : nil ] ) {
NSRunAlertPanel ( @ "Attention!" ,
@ "The file %@ could not be copied to %@!" ,
@ "OK" , nil , nil , newFile , destination ) ;
}
2001-01-06 16:26:01 +00:00
}
2000-08-27 19:11:42 +00:00
}
- ( void ) removeFile : ( NSString * ) file forKey : ( NSString * ) key
{
NSMutableArray * array ;
if ( ! file || ! key ) {
return ;
}
array = [ NSMutableArray arrayWithArray : [ projectDict objectForKey : key ] ] ;
[ array removeObject : file ] ;
[ projectDict setObject : array forKey : key ] ;
2002-01-02 16:05:02 +00:00
[ projectWindow setDocumentEdited : YES ] ;
2000-08-27 19:11:42 +00:00
}
- ( BOOL ) removeSelectedFilePermanently : ( BOOL ) yn
{
NSString * file = [ browserController nameOfSelectedFile ] ;
NSMutableArray * array ;
NSString * key ;
2000-09-17 12:13:10 +00:00
NSString * otherKey ;
NSString * ext ;
NSString * fn ;
BOOL ret = NO ;
2000-08-27 19:11:42 +00:00
if ( ! file ) {
return NO ;
}
key = [ self projectKeyForKeyPath : [ browserController pathOfSelectedFile ] ] ;
[ self removeFile : file forKey : key ] ;
2000-09-17 12:13:10 +00:00
if ( [ key isEqualToString : PCClasses ] ) {
otherKey = PCHeaders ;
ext = [ NSString stringWithString : @ "h" ] ;
fn = [ file stringByDeletingPathExtension ] ;
fn = [ fn stringByAppendingPathExtension : ext ] ;
if ( [ self doesAcceptFile : fn forKey : otherKey ] = = NO ) {
ret = NSRunAlertPanel ( @ "Removing Header?" , @ "Should %@ be removed from the project %@ as well?" , @ "Yes" , @ "No" , nil , fn , [ self projectName ] ) ;
}
}
else if ( [ key isEqualToString : PCHeaders ] ) {
otherKey = PCClasses ;
ext = [ NSString stringWithString : @ "m" ] ;
fn = [ file stringByDeletingPathExtension ] ;
fn = [ fn stringByAppendingPathExtension : ext ] ;
if ( [ self doesAcceptFile : fn forKey : otherKey ] = = NO ) {
ret = NSRunAlertPanel ( @ "Removing Class?" , @ "Should %@ be removed from the project %@ as well?" , @ "Yes" , @ "No" , nil , fn , [ self projectName ] ) ;
}
}
if ( ret ) {
[ self removeFile : fn forKey : otherKey ] ;
}
2000-08-27 19:11:42 +00:00
// Remove the file permanently ? !
if ( yn ) {
NSString * pth = [ projectPath stringByAppendingPathComponent : file ] ;
[ [ NSFileManager defaultManager ] removeFileAtPath : pth handler : nil ] ;
2000-09-17 12:13:10 +00:00
if ( ret ) {
pth = [ projectPath stringByAppendingPathComponent : fn ] ;
[ [ NSFileManager defaultManager ] removeFileAtPath : pth handler : nil ] ;
}
2000-08-27 19:11:42 +00:00
}
return YES ;
}
2000-10-15 18:24:09 +00:00
- ( void ) renameFile : ( NSString * ) aFile
{
}
2000-08-27 19:11:42 +00:00
- ( BOOL ) assignProjectDict : ( NSDictionary * ) aDict
{
NSAssert ( aDict , @ "No valid project dictionary!" ) ;
[ projectDict autorelease ] ;
projectDict = [ [ NSMutableDictionary alloc ] initWithDictionary : aDict ] ;
[ self setProjectName : [ projectDict objectForKey : PCProjectName ] ] ;
[ projectWindow setTitle : [ NSString stringWithFormat : @ "%@ - %@" , projectName , projectPath ] ] ;
2002-01-02 16:05:02 +00:00
// Update the interface
2000-11-10 18:27:15 +00:00
[ self updateValuesFromProjectDict ] ;
2000-08-27 19:11:42 +00:00
[ [ NSNotificationCenter defaultCenter ] postNotificationName : @ "ProjectDictDidChangeNotification" object : self ] ;
return YES ;
}
- ( NSDictionary * ) projectDict
{
return ( NSDictionary * ) projectDict ;
}
- ( void ) setProjectPath : ( NSString * ) aPath
{
[ projectPath autorelease ] ;
projectPath = [ aPath copy ] ;
}
- ( NSString * ) projectPath
{
return projectPath ;
}
- ( NSDictionary * ) rootCategories
{
return rootCategories ;
}
- ( BOOL ) save
{
2001-12-29 14:09:39 +00:00
BOOL ret = NO ;
2002-01-07 09:37:19 +00:00
NSString * file = [ [ projectPath stringByAppendingPathComponent : projectName ] stringByAppendingPathExtension : @ "pcproj" ] ;
2001-12-29 14:09:39 +00:00
NSString * backup = [ file stringByAppendingPathExtension : @ "backup" ] ;
NSFileManager * fm = [ NSFileManager defaultManager ] ;
NSUserDefaults * defs = [ NSUserDefaults standardUserDefaults ] ;
NSString * keepBackup = [ defs objectForKey : KeepBackup ] ;
BOOL shouldKeep = [ keepBackup isEqualToString : @ "YES" ] ;
2001-12-29 14:41:43 +00:00
if ( shouldKeep = = YES && [ fm isWritableFileAtPath : backup ] ) {
ret = [ fm removeFileAtPath : backup handler : nil ] ;
if ( ret = = NO ) {
NSRunAlertPanel ( @ "Attention!" ,
@ "Could not remove the old project backup '%@'!" ,
@ "OK" , nil , nil , backup ) ;
}
2001-12-29 14:09:39 +00:00
}
if ( shouldKeep && [ fm isReadableFileAtPath : file ] ) {
ret = [ fm copyPath : file toPath : backup handler : nil ] ;
if ( ret = = NO ) {
NSRunAlertPanel ( @ "Attention!" ,
2001-12-29 14:41:43 +00:00
@ "Could not save the project backup file '%@'!" ,
@ "OK" , nil , nil , file ) ;
2001-12-29 14:09:39 +00:00
}
}
ret = [ projectDict writeToFile : file atomically : YES ] ;
2002-01-02 16:05:02 +00:00
if ( ret = = YES )
{
[ projectWindow setDocumentEdited : NO ] ;
}
[ self writeMakefile ] ;
2001-12-29 14:09:39 +00:00
return ret ;
2000-08-27 19:11:42 +00:00
}
- ( BOOL ) saveAt : ( NSString * ) projPath
{
2001-12-29 14:09:39 +00:00
return NO ;
2000-08-27 19:11:42 +00:00
}
2002-02-02 19:21:00 +00:00
- ( BOOL ) saveFile
2000-08-27 19:11:42 +00:00
{
2002-02-02 19:21:00 +00:00
return [ editorController saveFile ] ;
2000-08-27 19:11:42 +00:00
}
- ( BOOL ) saveAllFiles
{
2001-12-29 14:09:39 +00:00
BOOL ret = NO ;
return ret ;
2000-08-27 19:11:42 +00:00
}
- ( BOOL ) saveAllFilesIfNeeded
{
2001-12-29 14:09:39 +00:00
BOOL ret = YES ;
return ret ;
2000-08-27 19:11:42 +00:00
}
2002-02-02 19:21:00 +00:00
- ( BOOL ) revertFile
{
return [ editorController revertFile ] ;
}
2002-01-01 17:27:41 +00:00
- ( BOOL ) writeSpecFile
{
NSString * name = [ projectDict objectForKey : PCProjectName ] ;
NSString * specInPath = [ projectPath stringByAppendingPathComponent : name ] ;
NSMutableString * specIn = [ NSMutableString string ] ;
if ( [ [ projectDict objectForKey : PCRelease ] intValue ] < 1 )
{
NSRunAlertPanel ( @ "Spec Input File Creation!" ,
@ "The Release entry seems to be wrong, please fix it!" ,
@ "OK" , nil , nil ) ;
return NO ;
}
specInPath = [ specInPath stringByAppendingPathExtension : @ "spec.in" ] ;
[ specIn appendString : @ "# Automatically generated by ProjectCenter.app\n" ] ;
[ specIn appendString : @ "#\nsummary: " ] ;
[ specIn appendString : [ projectDict objectForKey : PCSummary ] ] ;
[ specIn appendString : @ "\nRelease: " ] ;
[ specIn appendString : [ projectDict objectForKey : PCRelease ] ] ;
[ specIn appendString : @ "\nCopyright: " ] ;
[ specIn appendString : [ projectDict objectForKey : PCCopyright ] ] ;
[ specIn appendString : @ "\nGroup: " ] ;
[ specIn appendString : [ projectDict objectForKey : PCGroup ] ] ;
[ specIn appendString : @ "\nSource: " ] ;
[ specIn appendString : [ projectDict objectForKey : PCSource ] ] ;
[ specIn appendString : @ "\n\n%description\n\n" ] ;
[ specIn appendString : [ projectDict objectForKey : PCDescription ] ] ;
return [ specIn writeToFile : specInPath atomically : YES ] ;
}
2000-11-10 18:27:15 +00:00
// === === === === === === === === === === === === === === === === === === === === === === === === === = =
// === = Subprojects
// === === === === === === === === === === === === === === === === === === === === === === === === === = =
2000-08-27 19:11:42 +00:00
- ( NSArray * ) subprojects
{
return [ projectDict objectForKey : PCSubprojects ] ;
}
- ( void ) addSubproject : ( PCProject * ) aSubproject
{
}
- ( PCProject * ) superProject
{
return nil ;
}
- ( PCProject * ) rootProject
{
return self ;
}
- ( void ) newSubprojectNamed : ( NSString * ) aName
{
}
- ( void ) removeSubproject : ( PCProject * ) aSubproject
{
}
- ( BOOL ) isSubProject
{
2002-01-02 16:05:02 +00:00
return NO ;
2000-11-10 18:27:15 +00:00
}
// === === === === === === === === === === === === === === === === === === === === === === === === === = =
// === = Project Handling
// === === === === === === === === === === === === === === === === === === === === === === === === === = =
- ( void ) updateValuesFromProjectDict
{
2002-01-02 16:05:02 +00:00
[ projectTypeField setStringValue : [ projectDict objectForKey : PCProjType ] ] ;
[ installPathField setStringValue : [ projectDict objectForKey : PCInstallDir ] ] ;
[ toolField setStringValue : [ projectDict objectForKey : PCBuildTool ] ] ;
[ ccOptField setStringValue : [ projectDict objectForKey : PCCompilerOptions ] ] ;
[ ldOptField setStringValue : [ projectDict objectForKey : PCLinkerOptions ] ] ;
}
- ( void ) changeCommonProjectEntry : ( id ) sender
{
NSString * newEntry = [ sender stringValue ] ;
if ( sender = = installPathField )
{
[ projectDict setObject : newEntry forKey : PCInstallDir ] ;
}
else if ( sender = = toolField )
{
[ projectDict setObject : newEntry forKey : PCBuildTool ] ;
2002-01-02 17:43:11 +00:00
if ( ! [ [ NSFileManager defaultManager ] isExecutableFileAtPath : newEntry ] )
{
NSRunAlertPanel ( @ "Build Tool Error!" ,
@ "No valid executable found at '%@'!" ,
@ "OK" , nil , nil , newEntry ) ;
}
2002-01-02 16:05:02 +00:00
}
else if ( sender = = ccOptField )
{
[ projectDict setObject : newEntry forKey : PCCompilerOptions ] ;
}
else if ( sender = = ldOptField )
{
[ projectDict setObject : newEntry forKey : PCLinkerOptions ] ;
}
[ projectWindow setDocumentEdited : YES ] ;
2000-08-27 19:11:42 +00:00
}
2002-01-01 17:27:41 +00:00
- ( BOOL ) isValidDictionary : ( NSDictionary * ) aDict
{
NSString * _file ;
NSString * key ;
Class projClass = [ self builderClass ] ;
NSDictionary * origin ;
NSArray * keys ;
NSEnumerator * enumerator ;
_file = [ [ NSBundle bundleForClass : projClass ] pathForResource : @ "PC"
ofType : @ "proj" ] ;
origin = [ NSMutableDictionary dictionaryWithContentsOfFile : _file ] ;
keys = [ origin allKeys ] ;
enumerator = [ keys objectEnumerator ] ;
while ( key = [ enumerator nextObject ] )
{
if ( [ aDict objectForKey : key ] = = nil )
{
return NO ;
}
}
return YES ;
}
- ( void ) updateProjectDict
{
NSString * _file ;
NSString * key ;
Class projClass = [ self builderClass ] ;
NSDictionary * origin ;
NSArray * keys ;
NSEnumerator * enumerator ;
2002-01-02 16:05:02 +00:00
BOOL projectHasChanged = NO ;
2002-01-01 17:27:41 +00:00
_file = [ [ NSBundle bundleForClass : projClass ] pathForResource : @ "PC"
ofType : @ "proj" ] ;
origin = [ NSMutableDictionary dictionaryWithContentsOfFile : _file ] ;
keys = [ origin allKeys ] ;
enumerator = [ keys objectEnumerator ] ;
while ( key = [ enumerator nextObject ] )
{
if ( [ projectDict objectForKey : key ] = = nil )
{
[ projectDict setObject : [ origin objectForKey : key ] forKey : key ] ;
2002-01-02 16:05:02 +00:00
projectHasChanged = YES ;
2002-01-01 17:27:41 +00:00
NSRunAlertPanel ( @ "New Project Key!" ,
@ "The key '%@' has been added." ,
@ "OK" , nil , nil , key ) ;
}
}
2002-01-02 16:05:02 +00:00
if ( projectHasChanged = = YES )
{
[ projectWindow setDocumentEdited : YES ] ;
}
2002-01-01 17:27:41 +00:00
}
- ( void ) validateProjectDict
{
if ( [ self isValidDictionary : projectDict ] = = NO )
{
int ret = NSRunAlertPanel ( @ "Attention!" , @ "The project is not up to date, should it be updated automatically?" , @ "OK" , @ "No" , nil ) ;
if ( ret = = NSAlertDefaultReturn )
{
[ self updateProjectDict ] ;
[ self save ] ;
NSRunAlertPanel ( @ "Project updated!" , @ "The project file has been updated successfully!\nPlease make sure that all new project keys contain valid entries!" , @ "OK" , nil , nil ) ;
}
}
}
2000-08-27 19:11:42 +00:00
@ end
2002-02-11 22:19:39 +00:00
// === === === === === === === === === === === === === === === === === === === === === === === === === = =
// === === === === === === === === === === === === === === === === === === === === === === === === === = =
2000-08-27 19:11:42 +00:00
@ implementation PCProject ( ProjectKeyPaths )
- ( NSArray * ) contentAtKeyPath : ( NSString * ) keyPath
{
NSString * key ;
2000-11-01 10:38:57 +00:00
# ifdef DEBUG
2000-08-27 19:11:42 +00:00
NSLog ( @ "<%@ %x>: content at path %@" , [ self class ] , self , keyPath ) ;
2000-11-01 10:38:57 +00:00
# endif
2000-08-27 19:11:42 +00:00
if ( [ keyPath isEqualToString : @ "" ] || [ keyPath isEqualToString : @ "/" ] ) {
return [ rootCategories allKeys ] ;
}
key = [ [ keyPath componentsSeparatedByString : @ "/" ] lastObject ] ;
return [ projectDict objectForKey : [ rootCategories objectForKey : key ] ] ;
}
- ( BOOL ) hasChildrenAtKeyPath : ( NSString * ) keyPath
{
NSString * key ;
if ( ! keyPath || [ keyPath isEqualToString : @ "" ] ) {
return NO ;
}
key = [ [ keyPath componentsSeparatedByString : @ "/" ] lastObject ] ;
2000-09-17 12:13:10 +00:00
if ( [ [ rootCategories allKeys ] containsObject : key ] ||
[ [ projectDict objectForKey : PCSubprojects ] containsObject : key ] ) {
2000-08-27 19:11:42 +00:00
return YES ;
}
return NO ;
}
- ( NSString * ) projectKeyForKeyPath : ( NSString * ) kp
{
2000-09-17 12:13:10 +00:00
NSString * type = [ [ kp componentsSeparatedByString : @ "/" ] objectAtIndex : 1 ] ;
return [ rootCategories objectForKey : type ] ;
2000-08-27 19:11:42 +00:00
}
@ end
@ implementation PCProject ( ProjectWindowDelegate )
2002-02-11 22:19:39 +00:00
- ( void ) windowDidResignKey : ( NSNotification * ) aNotification
{
if ( editorIsActive )
{
[ [ NSNotificationCenter defaultCenter ] postNotificationName : PCEditorDidResignKeyNotification object : self ] ;
}
}
2000-08-27 19:11:42 +00:00
- ( void ) windowDidBecomeKey : ( NSNotification * ) aNotification
{
2002-02-11 22:19:39 +00:00
if ( editorIsActive )
{
[ [ NSNotificationCenter defaultCenter ] postNotificationName : PCEditorDidBecomeKeyNotification object : self ] ;
}
2000-09-17 12:13:10 +00:00
[ projectManager setActiveProject : self ] ;
2000-08-27 19:11:42 +00:00
}
- ( void ) windowDidBecomeMain : ( NSNotification * ) aNotification
{
2000-09-17 12:13:10 +00:00
[ projectManager setActiveProject : self ] ;
2000-08-27 19:11:42 +00:00
}
- ( void ) windowWillClose : ( NSNotification * ) aNotification
{
2000-09-17 12:13:10 +00:00
id object = [ aNotification object ] ;
2000-10-15 12:27:52 +00:00
2002-02-02 17:56:44 +00:00
if ( object = = buildTargetPanel )
{
2000-09-17 12:13:10 +00:00
}
2002-02-02 17:56:44 +00:00
else if ( object = = [ self projectWindow ] )
{
if ( [ [ self projectWindow ] isDocumentEdited ] )
{
2001-01-07 12:12:17 +00:00
if ( NSRunAlertPanel ( @ "Project changed!" ,
2002-02-02 17:56:44 +00:00
@ "The project %@ has been edited! Should it be saved before closing?" ,
2002-01-02 16:05:02 +00:00
@ "Yes" , @ "No" , nil , [ self projectName ] ) )
{
2000-09-17 12:13:10 +00:00
[ self save ] ;
}
2000-08-27 19:11:42 +00:00
}
2002-02-02 17:56:44 +00:00
[ editorController closeAllEditors ] ;
2000-09-17 12:13:10 +00:00
2000-08-27 19:11:42 +00:00
// The PCProjectController is our delegate !
2001-01-07 12:12:17 +00:00
[ [ NSNotificationCenter defaultCenter ] removeObserver : browserController ] ;
2000-09-17 12:13:10 +00:00
[ projectManager closeProject : self ] ;
}
}
@ end