mirror of
https://github.com/gnustep/apps-projectcenter.git
synced 2025-02-19 01:51:09 +00:00
See Documentatio/Changelog
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/branches/UNSTABLE_0_4@19489 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c8894fe5a1
commit
0253107558
25 changed files with 733 additions and 465 deletions
|
@ -1,3 +1,29 @@
|
||||||
|
2004-06-09 Serg Stoyan <stoyan255@ukr.net>
|
||||||
|
|
||||||
|
* Library/PCProjectBrowser.[hm]:
|
||||||
|
(pathOfSelectedFile): renamed to pathToSelectedFile.
|
||||||
|
(nameOfSelectedCategory): implemented. Use it insetead PCProject's
|
||||||
|
-categoryForCategoryPath.
|
||||||
|
(pathToSelectedCategory): implemented.
|
||||||
|
(setPathForFile:category:): removed.
|
||||||
|
(reloadLastColumn): implemented.
|
||||||
|
|
||||||
|
* Modules/ApplicationProject/PCAppProject.m:
|
||||||
|
(renameFile:toFile:): remove calling of PCProjectBrowser's
|
||||||
|
setPathForFile:category.
|
||||||
|
|
||||||
|
* Modules/RenaissanceProject/ PCRenaissanceProject.m:
|
||||||
|
(renameFile:toFile:): ditto.
|
||||||
|
|
||||||
|
* Library/PCLoadedFilesPanel.m:
|
||||||
|
* Library/PCBuildPanel.m:
|
||||||
|
* Library/PCLaunchPanel.m:
|
||||||
|
(activeProjectDidChange:): return if root project wasn't changed.
|
||||||
|
|
||||||
|
* Library/PCProject.m:
|
||||||
|
(setProjectmanager:): don't set project components for subproject.
|
||||||
|
|
||||||
|
|
||||||
2004-06-02 Serg Stoyan <stoyan255@ukr.net>
|
2004-06-02 Serg Stoyan <stoyan255@ukr.net>
|
||||||
|
|
||||||
* Library/PCProjectManager (openProjectAt:): get project name from
|
* Library/PCProjectManager (openProjectAt:): get project name from
|
||||||
|
@ -10,7 +36,7 @@
|
||||||
* PCMenuController.m: disable "Tear-Off Editor Size" fields editing
|
* PCMenuController.m: disable "Tear-Off Editor Size" fields editing
|
||||||
if Project Editor is not tear-off or Editor is not "ProjectCenter".
|
if Project Editor is not tear-off or Editor is not "ProjectCenter".
|
||||||
Check only first arg of Editor value.
|
Check only first arg of Editor value.
|
||||||
|
|
||||||
2004-06-01 Serg Stoyan <stoyan255@ukr.net>
|
2004-06-01 Serg Stoyan <stoyan255@ukr.net>
|
||||||
|
|
||||||
* Finished on-the-fly applying "Tear-Off Panels" preferences.
|
* Finished on-the-fly applying "Tear-Off Panels" preferences.
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
@interface PCBuildPanel : NSPanel
|
@interface PCBuildPanel : NSPanel
|
||||||
{
|
{
|
||||||
PCProjectManager *projectManager;
|
PCProjectManager *projectManager;
|
||||||
|
PCProject *currentProject;
|
||||||
NSBox *contentBox;
|
NSBox *contentBox;
|
||||||
NSBox *emptyBox;
|
NSBox *emptyBox;
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,22 +121,28 @@
|
||||||
|
|
||||||
- (void)activeProjectDidChange:(NSNotification *)aNotif
|
- (void)activeProjectDidChange:(NSNotification *)aNotif
|
||||||
{
|
{
|
||||||
PCProject *activeProject = [projectManager rootActiveProject];
|
PCProject *rootProject = [projectManager rootActiveProject];
|
||||||
|
|
||||||
[self setTitle: [NSString stringWithFormat:
|
if (rootProject == currentProject)
|
||||||
@"%@ - Project Build", [activeProject projectName]]];
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentProject = rootProject;
|
||||||
|
|
||||||
PCLogInfo(self, @"activeProjectDidChange to: %@",
|
PCLogInfo(self, @"activeProjectDidChange to: %@",
|
||||||
[activeProject projectName]);
|
[rootProject projectName]);
|
||||||
|
|
||||||
if (!activeProject)
|
if (!rootProject)
|
||||||
{
|
{
|
||||||
[contentBox setContentView:emptyBox];
|
[contentBox setContentView:emptyBox];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
[self setTitle: [NSString stringWithFormat:
|
||||||
|
@"%@ - Project Build", [rootProject projectName]]];
|
||||||
[contentBox
|
[contentBox
|
||||||
setContentView:[[activeProject projectBuilder] componentView]];
|
setContentView:[[rootProject projectBuilder] componentView]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -543,10 +543,11 @@
|
||||||
|
|
||||||
- (BOOL)becomeFirstResponder
|
- (BOOL)becomeFirstResponder
|
||||||
{
|
{
|
||||||
|
NSLog(@"PCEditor: becomeFirstResponder");
|
||||||
[[NSNotificationCenter defaultCenter]
|
[[NSNotificationCenter defaultCenter]
|
||||||
postNotificationName:PCEditorDidBecomeActiveNotification
|
postNotificationName:PCEditorDidBecomeActiveNotification
|
||||||
object:self];
|
object:self];
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "PCFileCreator.h"
|
#include "PCFileCreator.h"
|
||||||
#include "PCProjectManager.h"
|
#include "PCProjectManager.h"
|
||||||
#include "PCProject.h"
|
#include "PCProject.h"
|
||||||
|
#include "PCProjectBrowser.h"
|
||||||
#include "PCServer.h"
|
#include "PCServer.h"
|
||||||
|
|
||||||
#include "PCLogController.h"
|
#include "PCLogController.h"
|
||||||
|
@ -362,12 +363,18 @@ static PCFileManager *_mgr = nil;
|
||||||
{
|
{
|
||||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||||
NSString *lastOpenDir = [ud objectForKey:@"LastOpenDirectory"];
|
NSString *lastOpenDir = [ud objectForKey:@"LastOpenDirectory"];
|
||||||
|
PCProject *project = [projectManager rootActiveProject];
|
||||||
|
NSString *selectedCategory = nil;
|
||||||
int retval;
|
int retval;
|
||||||
PCProject *project = [projectManager activeProject];
|
|
||||||
|
|
||||||
[self _createAddFilesPanel];
|
[self _createAddFilesPanel];
|
||||||
|
selectedCategory = [[project projectBrowser] nameOfSelectedCategory];
|
||||||
[fileTypePopup selectItemWithTitle:[project selectedRootCategory]];
|
if ([selectedCategory isEqualToString:@"Subprojects"])
|
||||||
|
{
|
||||||
|
[addFilesPanel setCanChooseFiles:NO];
|
||||||
|
[addFilesPanel setCanChooseDirectories:YES];
|
||||||
|
}
|
||||||
|
[fileTypePopup selectItemWithTitle:selectedCategory];
|
||||||
|
|
||||||
[self filesForAddPopupClicked:self];
|
[self filesForAddPopupClicked:self];
|
||||||
|
|
||||||
|
@ -382,7 +389,7 @@ static PCFileManager *_mgr = nil;
|
||||||
if (retval == NSOKButton)
|
if (retval == NSOKButton)
|
||||||
{
|
{
|
||||||
[ud setObject:[addFilesPanel directory] forKey:@"LastOpenDirectory"];
|
[ud setObject:[addFilesPanel directory] forKey:@"LastOpenDirectory"];
|
||||||
return [[[addFilesPanel filenames] mutableCopy] autorelease];
|
return [[addFilesPanel filenames] mutableCopy];
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
@interface PCLaunchPanel : NSPanel
|
@interface PCLaunchPanel : NSPanel
|
||||||
{
|
{
|
||||||
PCProjectManager *projectManager;
|
PCProjectManager *projectManager;
|
||||||
|
PCProject *currentProject;
|
||||||
NSBox *contentBox;
|
NSBox *contentBox;
|
||||||
NSBox *emptyBox;
|
NSBox *emptyBox;
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,19 +121,26 @@
|
||||||
|
|
||||||
- (void)activeProjectDidChange:(NSNotification *)aNotif
|
- (void)activeProjectDidChange:(NSNotification *)aNotif
|
||||||
{
|
{
|
||||||
PCProject *activeProject = [projectManager rootActiveProject];
|
PCProject *rootProject = [projectManager rootActiveProject];
|
||||||
|
|
||||||
[self setTitle: [NSString stringWithFormat:
|
if (rootProject == currentProject)
|
||||||
@"%@ - Launch", [activeProject projectName]]];
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!activeProject)
|
currentProject = rootProject;
|
||||||
|
|
||||||
|
if (!rootProject)
|
||||||
{
|
{
|
||||||
[contentBox setContentView:emptyBox];
|
[contentBox setContentView:emptyBox];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
[self setTitle: [NSString stringWithFormat:
|
||||||
|
@"%@ - Launch", [rootProject projectName]]];
|
||||||
|
|
||||||
[contentBox
|
[contentBox
|
||||||
setContentView:[[activeProject projectLauncher] componentView]];
|
setContentView:[[rootProject projectLauncher] componentView]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
@interface PCLoadedFilesPanel : NSPanel
|
@interface PCLoadedFilesPanel : NSPanel
|
||||||
{
|
{
|
||||||
PCProjectManager *projectManager;
|
PCProjectManager *projectManager;
|
||||||
|
PCProject *currentProject;
|
||||||
NSBox *contentBox;
|
NSBox *contentBox;
|
||||||
NSBox *emptyBox;
|
NSBox *emptyBox;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,22 +35,21 @@
|
||||||
{
|
{
|
||||||
PCProjectLoadedFiles *projectLoadedFiles = nil;
|
PCProjectLoadedFiles *projectLoadedFiles = nil;
|
||||||
PCProject *activeProject = nil;
|
PCProject *activeProject = nil;
|
||||||
|
|
||||||
projectManager = aManager;
|
projectManager = aManager;
|
||||||
activeProject = [projectManager rootActiveProject];
|
activeProject = [projectManager rootActiveProject];
|
||||||
|
currentProject = activeProject;
|
||||||
projectLoadedFiles = [activeProject projectLoadedFiles];
|
projectLoadedFiles = [activeProject projectLoadedFiles];
|
||||||
|
|
||||||
|
PCLogStatus(self, @"[init]");
|
||||||
|
|
||||||
self = [super initWithContentRect: NSMakeRect (0, 300, 220, 322)
|
self = [super initWithContentRect: NSMakeRect (0, 300, 220, 322)
|
||||||
styleMask: (NSTitledWindowMask
|
styleMask: (NSTitledWindowMask
|
||||||
| NSClosableWindowMask
|
| NSClosableWindowMask
|
||||||
| NSResizableWindowMask)
|
| NSResizableWindowMask)
|
||||||
backing: NSBackingStoreRetained
|
backing: NSBackingStoreRetained
|
||||||
defer: YES];
|
defer: YES];
|
||||||
[self setFloatingPanel:YES];
|
// [self setFloatingPanel:YES];
|
||||||
/* self = [super initWithContentRect: NSMakeRect (0, 300, 220, 322)
|
|
||||||
styleMask: NSUtilityWindowMask
|
|
||||||
backing: NSBackingStoreRetained
|
|
||||||
defer: YES];*/
|
|
||||||
[self setMinSize: NSMakeSize(120, 23)];
|
[self setMinSize: NSMakeSize(120, 23)];
|
||||||
[self setFrameAutosaveName: @"LoadedFiles"];
|
[self setFrameAutosaveName: @"LoadedFiles"];
|
||||||
[self setReleasedWhenClosed: NO];
|
[self setReleasedWhenClosed: NO];
|
||||||
|
@ -89,7 +88,7 @@
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
NSLog (@"PCLoadedFilesPanel: dealloc");
|
NSLog(@"PCLoadedFilesPanel: dealloc");
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
|
|
||||||
|
@ -112,36 +111,38 @@
|
||||||
|
|
||||||
- (void)close
|
- (void)close
|
||||||
{
|
{
|
||||||
PCLogInfo(self, @"close: %@", [contentBox contentView]);
|
|
||||||
|
|
||||||
[contentBox setContentView:emptyBox];
|
[contentBox setContentView:emptyBox];
|
||||||
|
|
||||||
PCLogInfo(self, @"close: %@", [contentBox contentView]);
|
|
||||||
|
|
||||||
[super close];
|
[super close];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*- (BOOL)canBecomeKeyWindow
|
|
||||||
{
|
|
||||||
// Panels controls doesn't receive mouse click if return NO
|
|
||||||
return YES;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
- (void)activeProjectDidChange:(NSNotification *)aNotif
|
- (void)activeProjectDidChange:(NSNotification *)aNotif
|
||||||
{
|
{
|
||||||
PCProject *activeProject = [projectManager rootActiveProject];
|
PCProject *rootProject = [projectManager rootActiveProject];
|
||||||
|
|
||||||
[self setTitle: [NSString stringWithFormat:
|
PCLogInfo(self, @"rootProject %@ currentProject %@",
|
||||||
@"%@ - Loaded Files", [activeProject projectName]]];
|
[rootProject projectName], [currentProject projectName]);
|
||||||
|
|
||||||
if (!activeProject)
|
if (rootProject == currentProject)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PCLogInfo(self, @"1--- rootProject %@ currentProject %@",
|
||||||
|
[rootProject projectName], [currentProject projectName]);
|
||||||
|
|
||||||
|
currentProject = rootProject;
|
||||||
|
|
||||||
|
if (!rootProject)
|
||||||
{
|
{
|
||||||
[contentBox setContentView:emptyBox];
|
[contentBox setContentView:emptyBox];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
[self setTitle: [NSString stringWithFormat:
|
||||||
|
@"%@ - Loaded Files", [rootProject projectName]]];
|
||||||
[contentBox
|
[contentBox
|
||||||
setContentView:[[activeProject projectLoadedFiles] componentView]];
|
setContentView:[[rootProject projectLoadedFiles] componentView]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ extern NSString *PCProjectDictDidSaveNotification;
|
||||||
- (BOOL)close:(id)sender;
|
- (BOOL)close:(id)sender;
|
||||||
- (void)dealloc;
|
- (void)dealloc;
|
||||||
|
|
||||||
- (BOOL)saveProjectWindowsAndPanels; // Not finished
|
- (BOOL)saveProjectWindowsAndPanels;
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// ==== Accessory methods
|
// ==== Accessory methods
|
||||||
|
@ -111,11 +111,6 @@ extern NSString *PCProjectDictDidSaveNotification;
|
||||||
- (void)setProjectName:(NSString *)aName;
|
- (void)setProjectName:(NSString *)aName;
|
||||||
- (BOOL)isProjectChanged;
|
- (BOOL)isProjectChanged;
|
||||||
|
|
||||||
- (NSString *)selectedRootCategory;
|
|
||||||
- (NSString *)selectedRootCategoryKey;
|
|
||||||
|
|
||||||
- (Class)principalClass;
|
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// ==== Can be overriden
|
// ==== Can be overriden
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
@ -178,7 +173,6 @@ extern NSString *PCProjectDictDidSaveNotification;
|
||||||
- (NSString *)categoryForKey:(NSString *)key;
|
- (NSString *)categoryForKey:(NSString *)key;
|
||||||
|
|
||||||
- (BOOL)save;
|
- (BOOL)save;
|
||||||
- (BOOL)saveAt:(NSString *)projPath;
|
|
||||||
|
|
||||||
- (BOOL)writeSpecFile;
|
- (BOOL)writeSpecFile;
|
||||||
|
|
||||||
|
@ -204,8 +198,9 @@ extern NSString *PCProjectDictDidSaveNotification;
|
||||||
- (PCProject *)subprojectWithName:(NSString *)name;
|
- (PCProject *)subprojectWithName:(NSString *)name;
|
||||||
|
|
||||||
- (void)addSubproject:(PCProject *)aSubproject;
|
- (void)addSubproject:(PCProject *)aSubproject;
|
||||||
- (void)newSubprojectNamed:(NSString *)aName;
|
- (void)addSubprojectWithName:(NSString *)name;
|
||||||
- (void)removeSubproject:(PCProject *)aSubproject;
|
- (BOOL)removeSubproject:(PCProject *)aSubproject;
|
||||||
|
- (BOOL)removeSubprojectWithName:(NSString *)subprojectName;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -216,7 +211,8 @@ extern NSString *PCProjectDictDidSaveNotification;
|
||||||
|
|
||||||
- (NSString *)rootCategoryForCategoryPath:(NSString *)categoryPath;
|
- (NSString *)rootCategoryForCategoryPath:(NSString *)categoryPath;
|
||||||
- (NSString *)categoryForCategoryPath:(NSString *)categoryPath;
|
- (NSString *)categoryForCategoryPath:(NSString *)categoryPath;
|
||||||
- (NSString *)keyForCategoryPath:(NSString *)kp;
|
- (NSString *)keyForRootCategoryInCategoryPath:(NSString *)categoryPath;
|
||||||
|
- (NSString *)keyForCategoryPath:(NSString *)categoryPath;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -99,19 +99,27 @@ NSString
|
||||||
{
|
{
|
||||||
projectManager = aManager;
|
projectManager = aManager;
|
||||||
|
|
||||||
if (!projectBrowser)
|
if (isSubproject)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!projectBrowser && !isSubproject)
|
||||||
{
|
{
|
||||||
projectBrowser = [[PCProjectBrowser alloc] initWithProject:self];
|
projectBrowser = [[PCProjectBrowser alloc] initWithProject:self];
|
||||||
}
|
}
|
||||||
if (!projectLoadedFiles)
|
|
||||||
|
if (!projectLoadedFiles && !isSubproject)
|
||||||
{
|
{
|
||||||
projectLoadedFiles = [[PCProjectLoadedFiles alloc] initWithProject:self];
|
projectLoadedFiles = [[PCProjectLoadedFiles alloc] initWithProject:self];
|
||||||
}
|
}
|
||||||
if (!projectEditor)
|
|
||||||
|
if (!projectEditor && !isSubproject)
|
||||||
{
|
{
|
||||||
projectEditor = [[PCProjectEditor alloc] initWithProject:self];
|
projectEditor = [[PCProjectEditor alloc] initWithProject:self];
|
||||||
}
|
}
|
||||||
if (!projectWindow)
|
|
||||||
|
if (!projectWindow && !isSubproject)
|
||||||
{
|
{
|
||||||
projectWindow = [[PCProjectWindow alloc] initWithProject:self];
|
projectWindow = [[PCProjectWindow alloc] initWithProject:self];
|
||||||
}
|
}
|
||||||
|
@ -265,6 +273,10 @@ NSString
|
||||||
[windows removeObjectForKey:@"LoadedFiles"];
|
[windows removeObjectForKey:@"LoadedFiles"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set to project dict for case if project changed
|
||||||
|
// Don't notify about projectDict changes
|
||||||
|
[projectDict setObject:windows forKey:@"PC_WINDOWS"];
|
||||||
|
|
||||||
// Now save it directly to PC.project file
|
// Now save it directly to PC.project file
|
||||||
[projectFileDict setObject:windows forKey:@"PC_WINDOWS"];
|
[projectFileDict setObject:windows forKey:@"PC_WINDOWS"];
|
||||||
[projectFileDict writeToFile:projectFile atomically:YES];
|
[projectFileDict writeToFile:projectFile atomically:YES];
|
||||||
|
@ -314,6 +326,11 @@ NSString
|
||||||
return projectManager;
|
return projectManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (PCProjectWindow *)projectWindow
|
||||||
|
{
|
||||||
|
return projectWindow;
|
||||||
|
}
|
||||||
|
|
||||||
- (PCProjectBrowser *)projectBrowser
|
- (PCProjectBrowser *)projectBrowser
|
||||||
{
|
{
|
||||||
return projectBrowser;
|
return projectBrowser;
|
||||||
|
@ -354,23 +371,6 @@ NSString
|
||||||
return projectEditor;
|
return projectEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)selectedRootCategory
|
|
||||||
{
|
|
||||||
NSString *_path = [[self projectBrowser] pathOfSelectedFile];
|
|
||||||
|
|
||||||
return [self categoryForCategoryPath:_path];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSString *)selectedRootCategoryKey
|
|
||||||
{
|
|
||||||
NSString *_path = [[self projectBrowser] pathOfSelectedFile];
|
|
||||||
NSString *key = [self keyForCategoryPath:_path];
|
|
||||||
|
|
||||||
PCLogInfo(self, @"selected category: %@. key: %@", _path, key);
|
|
||||||
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)setProjectDictObject:(id)object forKey:(NSString *)key
|
- (void)setProjectDictObject:(id)object forKey:(NSString *)key
|
||||||
{
|
{
|
||||||
id currentObject = [projectDict objectForKey:key];
|
id currentObject = [projectDict objectForKey:key];
|
||||||
|
@ -400,21 +400,11 @@ NSString
|
||||||
return projectName;
|
return projectName;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (PCProjectWindow *)projectWindow
|
|
||||||
{
|
|
||||||
return projectWindow;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)isProjectChanged
|
- (BOOL)isProjectChanged
|
||||||
{
|
{
|
||||||
return [projectWindow isDocumentEdited];
|
return [projectWindow isDocumentEdited];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (Class)principalClass
|
|
||||||
{
|
|
||||||
return [self class];
|
|
||||||
}
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// ==== Can be overriden
|
// ==== Can be overriden
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
@ -523,17 +513,14 @@ NSString
|
||||||
return projectPath;
|
return projectPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- (NSArray *)complementaryTypesForType:(NSString *)type
|
|
||||||
- (NSString *)complementaryTypeForType:(NSString *)type
|
- (NSString *)complementaryTypeForType:(NSString *)type
|
||||||
{
|
{
|
||||||
if ([type isEqualToString:@"m"] || [type isEqualToString:@"c"])
|
if ([type isEqualToString:@"m"] || [type isEqualToString:@"c"])
|
||||||
{
|
{
|
||||||
// return [NSArray arrayWithObjects:@"h",nil];
|
|
||||||
return [NSString stringWithString:@"h"];
|
return [NSString stringWithString:@"h"];
|
||||||
}
|
}
|
||||||
else if ([type isEqualToString:@"h"])
|
else if ([type isEqualToString:@"h"])
|
||||||
{
|
{
|
||||||
// return [NSArray arrayWithObjects:@"m",@"c",nil];
|
|
||||||
return [NSString stringWithString:@"m"];
|
return [NSString stringWithString:@"m"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -617,10 +604,11 @@ NSString
|
||||||
complementaryTypeForType:[[files objectAtIndex:0] pathExtension]];
|
complementaryTypeForType:[[files objectAtIndex:0] pathExtension]];
|
||||||
if (complementaryType)
|
if (complementaryType)
|
||||||
{
|
{
|
||||||
complementaryKey =
|
complementaryKey = [self categoryKeyForFileType:complementaryType];
|
||||||
[self categoryKeyForFileType:complementaryType];
|
|
||||||
complementaryDir = [self dirForCategoryKey:complementaryKey];
|
complementaryDir = [self dirForCategoryKey:complementaryKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PCLogInfo(self, @"{%@} {addAndCopyFiles} %@", projectName, fileList);
|
||||||
|
|
||||||
// Validate files
|
// Validate files
|
||||||
while ((file = [fileEnum nextObject]))
|
while ((file = [fileEnum nextObject]))
|
||||||
|
@ -635,13 +623,16 @@ NSString
|
||||||
|
|
||||||
compFile = [[file stringByDeletingPathExtension]
|
compFile = [[file stringByDeletingPathExtension]
|
||||||
stringByAppendingPathExtension:complementaryType];
|
stringByAppendingPathExtension:complementaryType];
|
||||||
if ([[NSFileManager defaultManager] fileExistsAtPath:compFile])
|
if ([[NSFileManager defaultManager] fileExistsAtPath:compFile]
|
||||||
|
&& [self doesAcceptFile:compFile forKey:complementaryKey])
|
||||||
{
|
{
|
||||||
[complementaryFiles addObject:compFile];
|
[complementaryFiles addObject:compFile];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PCLogInfo(self, @"{addAndCopyFiles} %@", fileList);
|
||||||
|
|
||||||
// Copy files
|
// Copy files
|
||||||
if (![key isEqualToString:PCLibraries]) // Don't copy libraries
|
if (![key isEqualToString:PCLibraries]) // Don't copy libraries
|
||||||
{
|
{
|
||||||
|
@ -690,11 +681,7 @@ NSString
|
||||||
[projectFiles addObject:pFile];
|
[projectFiles addObject:pFile];
|
||||||
}
|
}
|
||||||
|
|
||||||
[projectDict setObject:projectFiles forKey:type];
|
[self setProjectDictObject:projectFiles forKey:type];
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter]
|
|
||||||
postNotificationName:PCProjectDictDidChangeNotification
|
|
||||||
object:self];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)removeFiles:(NSArray *)files forKey:(NSString *)key
|
- (BOOL)removeFiles:(NSArray *)files forKey:(NSString *)key
|
||||||
|
@ -711,7 +698,7 @@ NSString
|
||||||
{
|
{
|
||||||
if ([key isEqualToString:PCSubprojects])
|
if ([key isEqualToString:PCSubprojects])
|
||||||
{
|
{
|
||||||
[self removeSubproject:[self subprojectWithName:file]];
|
[self removeSubprojectWithName:file];
|
||||||
}
|
}
|
||||||
[projectFiles removeObject:file];
|
[projectFiles removeObject:file];
|
||||||
|
|
||||||
|
@ -720,33 +707,34 @@ NSString
|
||||||
[projectEditor closeEditorForFile:filePath];
|
[projectEditor closeEditorForFile:filePath];
|
||||||
}
|
}
|
||||||
|
|
||||||
[projectDict setObject:projectFiles forKey:key];
|
[self setProjectDictObject:projectFiles forKey:key];
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter]
|
|
||||||
postNotificationName:PCProjectDictDidChangeNotification
|
|
||||||
object:self];
|
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)renameFile:(NSString *)fromFile toFile:(NSString *)toFile
|
- (BOOL)renameFile:(NSString *)fromFile toFile:(NSString *)toFile
|
||||||
{
|
{
|
||||||
NSFileManager *fm = [NSFileManager defaultManager];
|
NSFileManager *fm = [NSFileManager defaultManager];
|
||||||
NSString *selectedCategory = [self selectedRootCategory];
|
NSString *selectedCategory = nil;
|
||||||
NSString *selectedCategoryKey = [self selectedRootCategoryKey];
|
NSString *selectedCategoryKey = nil;
|
||||||
NSString *fromPath = nil;
|
NSString *fromPath = nil;
|
||||||
NSString *toPath = nil;
|
NSString *toPath = nil;
|
||||||
NSMutableDictionary *_pDict = nil;
|
NSMutableDictionary *_pDict = nil;
|
||||||
NSString *_file = nil;
|
NSString *_file = nil;
|
||||||
NSMutableArray *_array = nil;
|
NSMutableArray *_array = nil;
|
||||||
BOOL saveToFile = NO;
|
BOOL saveToFile = NO;
|
||||||
|
|
||||||
|
selectedCategory = [projectBrowser nameOfSelectedCategory];
|
||||||
|
selectedCategoryKey = [[projectManager rootActiveProject]
|
||||||
|
keyForCategory:selectedCategory];
|
||||||
|
|
||||||
fromPath = [[self dirForCategoryKey:selectedCategoryKey]
|
fromPath = [[self dirForCategoryKey:selectedCategoryKey]
|
||||||
stringByAppendingPathComponent:fromFile];
|
stringByAppendingPathComponent:fromFile];
|
||||||
toPath = [[self dirForCategoryKey:selectedCategoryKey]
|
toPath = [[self dirForCategoryKey:selectedCategoryKey]
|
||||||
stringByAppendingPathComponent:toFile];
|
stringByAppendingPathComponent:toFile];
|
||||||
|
|
||||||
PCLogInfo(self, @"move %@ to %@", fromPath, toPath);
|
PCLogInfo(self, @"{%@} move %@ to %@ category: %@",
|
||||||
|
projectName, fromPath, toPath, selectedCategory);
|
||||||
|
|
||||||
if ([fm movePath:fromPath toPath:toPath handler:nil] == YES)
|
if ([fm movePath:fromPath toPath:toPath handler:nil] == YES)
|
||||||
{
|
{
|
||||||
|
@ -778,8 +766,11 @@ NSString
|
||||||
{
|
{
|
||||||
[self save];
|
[self save];
|
||||||
}
|
}
|
||||||
|
|
||||||
[projectBrowser setPathForFile:toFile category:selectedCategory];
|
// Set browser path to new file name
|
||||||
|
[projectBrowser
|
||||||
|
setPath:[[projectBrowser pathToSelectedCategory]
|
||||||
|
stringByAppendingPathComponent:toFile]];
|
||||||
}
|
}
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
|
@ -842,10 +833,8 @@ NSString
|
||||||
return rootEntries;
|
return rootEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Category is the name we see in project browser, e.g.
|
// Category - the name we see in project browser, e.g. "Classes"
|
||||||
// Classes.
|
// Key - the uppercase names located in PC.roject, e.g. "CLASS_FILES"
|
||||||
// Key is the uppercase names which are located in PC.roject, e.g.
|
|
||||||
// CLASS_FILES
|
|
||||||
- (NSString *)keyForCategory:(NSString *)category
|
- (NSString *)keyForCategory:(NSString *)category
|
||||||
{
|
{
|
||||||
int index = [rootCategories indexOfObject:category];
|
int index = [rootCategories indexOfObject:category];
|
||||||
|
@ -919,11 +908,6 @@ NSString
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)saveAt:(NSString *)projPath
|
|
||||||
{
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)writeSpecFile
|
- (BOOL)writeSpecFile
|
||||||
{
|
{
|
||||||
NSString *name = [projectDict objectForKey:PCProjectName];
|
NSString *name = [projectDict objectForKey:PCProjectName];
|
||||||
|
@ -987,12 +971,11 @@ NSString
|
||||||
- (void)updateProjectDict
|
- (void)updateProjectDict
|
||||||
{
|
{
|
||||||
Class projClass = [self builderClass];
|
Class projClass = [self builderClass];
|
||||||
NSString *_file;
|
NSString *_file = nil;
|
||||||
NSString *key;
|
NSString *key = nil;
|
||||||
NSDictionary *origin;
|
NSDictionary *origin = nil;
|
||||||
NSArray *keys;
|
NSArray *keys = nil;
|
||||||
NSEnumerator *enumerator;
|
NSEnumerator *enumerator = nil;
|
||||||
BOOL projectHasChanged = NO;
|
|
||||||
|
|
||||||
_file = [[NSBundle bundleForClass:projClass] pathForResource:@"PC"
|
_file = [[NSBundle bundleForClass:projClass] pathForResource:@"PC"
|
||||||
ofType:@"project"];
|
ofType:@"project"];
|
||||||
|
@ -1005,21 +988,12 @@ NSString
|
||||||
{
|
{
|
||||||
if ([projectDict objectForKey:key] == nil)
|
if ([projectDict objectForKey:key] == nil)
|
||||||
{
|
{
|
||||||
|
// Doesn't call setProjectDictObject:forKey for opimizations
|
||||||
[projectDict setObject:[origin objectForKey:key] forKey:key];
|
[projectDict setObject:[origin objectForKey:key] forKey:key];
|
||||||
projectHasChanged = YES;
|
|
||||||
|
|
||||||
/* NSRunAlertPanel(@"New Project Key!",
|
|
||||||
@"The key '%@' has been added.",
|
|
||||||
@"OK",nil,nil,key);*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (projectHasChanged == YES)
|
[self save];
|
||||||
{
|
|
||||||
[[NSNotificationCenter defaultCenter]
|
|
||||||
postNotificationName:PCProjectDictDidChangeNotification
|
|
||||||
object:self];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)validateProjectDict
|
- (void)validateProjectDict
|
||||||
|
@ -1033,7 +1007,6 @@ NSString
|
||||||
if (ret == NSAlertDefaultReturn)
|
if (ret == NSAlertDefaultReturn)
|
||||||
{
|
{
|
||||||
[self updateProjectDict];
|
[self updateProjectDict];
|
||||||
[self save];
|
|
||||||
|
|
||||||
NSRunAlertPanel(@"Project updated!",
|
NSRunAlertPanel(@"Project updated!",
|
||||||
@"The project file has been updated successfully!\nPlease make sure that all new project keys contain valid entries!",
|
@"The project file has been updated successfully!\nPlease make sure that all new project keys contain valid entries!",
|
||||||
|
@ -1098,7 +1071,9 @@ NSString
|
||||||
// Subproject in project but not loaded
|
// Subproject in project but not loaded
|
||||||
if ([[projectDict objectForKey:PCSubprojects] containsObject:name])
|
if ([[projectDict objectForKey:PCSubprojects] containsObject:name])
|
||||||
{
|
{
|
||||||
// Search for subproject with name in subprojects array
|
PCLogInfo(self, @"{%@}Searching for loaded subproject: %@",
|
||||||
|
projectName, name);
|
||||||
|
// Search for subproject with name among loaded subprojects
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
sp = [loadedSubprojects objectAtIndex:i];
|
sp = [loadedSubprojects objectAtIndex:i];
|
||||||
|
@ -1110,27 +1085,37 @@ NSString
|
||||||
sp = nil;
|
sp = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Subproject not found in array, load subproject
|
// Subproject not found in array, load it
|
||||||
if (sp == nil)
|
if (sp == nil)
|
||||||
{
|
{
|
||||||
spFile = [projectPath stringByAppendingPathComponent:name];
|
spFile = [projectPath stringByAppendingPathComponent:name];
|
||||||
spFile = [spFile stringByAppendingPathExtension:@"subproj"];
|
spFile = [spFile stringByAppendingPathExtension:@"subproj"];
|
||||||
spFile = [spFile stringByAppendingPathComponent:@"PC.project"];
|
spFile = [spFile stringByAppendingPathComponent:@"PC.project"];
|
||||||
|
PCLogInfo(self, @"Not found! Load subproject: %@ at path: %@",
|
||||||
|
name, spFile);
|
||||||
sp = [projectManager loadProjectAt:spFile];
|
sp = [projectManager loadProjectAt:spFile];
|
||||||
[sp setIsSubproject:YES];
|
if (sp)
|
||||||
[sp setSuperProject:self];
|
{
|
||||||
[loadedSubprojects addObject:sp];
|
[sp setIsSubproject:YES];
|
||||||
|
[sp setSuperProject:self];
|
||||||
|
[sp setProjectManager:projectManager];
|
||||||
|
[loadedSubprojects addObject:sp];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sp;
|
return sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)addSubproject:(PCProject *)aSubproject
|
- (void)addSubproject:(PCProject *)aSubproject
|
||||||
{
|
{
|
||||||
NSMutableArray *_subprojects;
|
NSMutableArray *_subprojects;
|
||||||
|
|
||||||
|
if (!aSubproject)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_subprojects = [NSMutableArray
|
_subprojects = [NSMutableArray
|
||||||
arrayWithArray:[projectDict objectForKey:PCSubprojects]];
|
arrayWithArray:[projectDict objectForKey:PCSubprojects]];
|
||||||
|
|
||||||
|
@ -1139,67 +1124,95 @@ NSString
|
||||||
[self setProjectDictObject:_subprojects forKey:PCSubprojects];
|
[self setProjectDictObject:_subprojects forKey:PCSubprojects];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)newSubprojectNamed:(NSString *)aName
|
- (void)addSubprojectWithName:(NSString *)name
|
||||||
{
|
{
|
||||||
|
NSMutableArray *_subprojects = nil;
|
||||||
|
|
||||||
|
if (!name)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_subprojects = [NSMutableArray
|
||||||
|
arrayWithArray:[projectDict objectForKey:PCSubprojects]];
|
||||||
|
[_subprojects addObject:name];
|
||||||
|
[self setProjectDictObject:_subprojects forKey:PCSubprojects];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)removeSubproject:(PCProject *)aSubproject
|
- (BOOL)removeSubprojectWithName:(NSString *)subprojectName
|
||||||
|
{
|
||||||
|
NSString *extension = [subprojectName pathExtension];
|
||||||
|
NSString *sName = subprojectName;
|
||||||
|
|
||||||
|
if (extension && [extension isEqualToString:@"subproj"])
|
||||||
|
{
|
||||||
|
sName = [subprojectName stringByDeletingPathExtension];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [self removeSubproject:[self subprojectWithName:sName]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)removeSubproject:(PCProject *)aSubproject
|
||||||
{
|
{
|
||||||
if ([loadedSubprojects containsObject:aSubproject])
|
if ([loadedSubprojects containsObject:aSubproject])
|
||||||
{
|
{
|
||||||
[aSubproject close:self];
|
[aSubproject close:self];
|
||||||
[loadedSubprojects removeObject:aSubproject];
|
[loadedSubprojects removeObject:aSubproject];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation PCProject (CategoryPaths)
|
@implementation PCProject (CategoryPaths)
|
||||||
|
// TODO: Think about moving all category related methods into PCProjectBrowser
|
||||||
|
|
||||||
- (NSArray *)contentAtCategoryPath:(NSString *)categoryPath
|
- (NSArray *)contentAtCategoryPath:(NSString *)categoryPath
|
||||||
{
|
{
|
||||||
NSString *key = [self keyForCategoryPath:categoryPath];
|
NSString *key = [self keyForRootCategoryInCategoryPath:categoryPath];
|
||||||
NSArray *pathArray = nil;
|
NSArray *pathArray = nil;
|
||||||
|
|
||||||
pathArray = [categoryPath componentsSeparatedByString:@"/"];
|
pathArray = [categoryPath componentsSeparatedByString:@"/"];
|
||||||
|
|
||||||
|
PCLogInfo(self, @"{%@}{contentAtCategoryPath:} %@",
|
||||||
|
projectName, categoryPath);
|
||||||
|
|
||||||
|
// Click on /Category
|
||||||
if ([pathArray count] == 2)
|
if ([pathArray count] == 2)
|
||||||
{
|
{
|
||||||
[projectManager setActiveProject:self];
|
if ([projectManager activeProject] != self)
|
||||||
|
{
|
||||||
|
[projectManager setActiveProject:self];
|
||||||
|
}
|
||||||
activeSubproject = nil;
|
activeSubproject = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([categoryPath isEqualToString:@""] || [categoryPath isEqualToString:@"/"])
|
if ([categoryPath isEqualToString:@""] || [categoryPath isEqualToString:@"/"])
|
||||||
{
|
{
|
||||||
|
if ([projectManager activeProject] != self)
|
||||||
|
{
|
||||||
|
[projectManager setActiveProject:self];
|
||||||
|
}
|
||||||
return rootCategories;
|
return rootCategories;
|
||||||
}
|
}
|
||||||
else if ([key isEqualToString:PCSubprojects])
|
else if ([key isEqualToString:PCSubprojects] && [pathArray count] > 2)
|
||||||
{
|
{ // Click on "/Subprojects/Name+"
|
||||||
PCProject *_subproject = nil;
|
PCProject *_subproject = nil;
|
||||||
NSString *spCategoryPath = nil;
|
NSString *spCategoryPath = nil;
|
||||||
NSMutableArray *mCategoryPath = nil;
|
NSMutableArray *mCategoryPath = nil;
|
||||||
|
|
||||||
mCategoryPath = [pathArray mutableCopy];
|
mCategoryPath = [pathArray mutableCopy];
|
||||||
|
|
||||||
if ([pathArray count] == 2)
|
_subproject = [self subprojectWithName:[pathArray objectAtIndex:2]];
|
||||||
{ // Click on "/Subprojects"
|
activeSubproject = _subproject;
|
||||||
return [projectDict objectForKey:PCSubprojects];
|
|
||||||
}
|
|
||||||
else if ([pathArray count] > 2)
|
|
||||||
{ // CLick on "/Subprojects/Name.subproj+"
|
|
||||||
_subproject = [self
|
|
||||||
subprojectWithName:[pathArray objectAtIndex:2]];
|
|
||||||
|
|
||||||
[projectManager setActiveProject:_subproject];
|
[mCategoryPath removeObjectAtIndex:1];
|
||||||
activeSubproject = _subproject;
|
[mCategoryPath removeObjectAtIndex:1];
|
||||||
|
|
||||||
[mCategoryPath removeObjectAtIndex:1];
|
spCategoryPath = [mCategoryPath componentsJoinedByString:@"/"];
|
||||||
[mCategoryPath removeObjectAtIndex:1];
|
|
||||||
|
|
||||||
spCategoryPath = [mCategoryPath componentsJoinedByString:@"/"];
|
return [_subproject contentAtCategoryPath:spCategoryPath];
|
||||||
|
|
||||||
return [_subproject contentAtCategoryPath:spCategoryPath];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [projectDict objectForKey:key];
|
return [projectDict objectForKey:key];
|
||||||
|
@ -1207,11 +1220,29 @@ NSString
|
||||||
|
|
||||||
- (BOOL)hasChildrenAtCategoryPath:(NSString *)categoryPath
|
- (BOOL)hasChildrenAtCategoryPath:(NSString *)categoryPath
|
||||||
{
|
{
|
||||||
NSString *listEntry = nil;
|
NSString *listEntry = nil;
|
||||||
|
NSString *categoryKey = nil;
|
||||||
|
NSString *category = nil;
|
||||||
|
PCProject *activeProject = [projectManager activeProject];
|
||||||
|
|
||||||
|
if (self != activeProject)
|
||||||
|
{
|
||||||
|
return [activeProject hasChildrenAtCategoryPath:categoryPath];
|
||||||
|
}
|
||||||
|
|
||||||
|
PCLogInfo(self, @"{%@} hasChildrenAtCategoryPath: %@",
|
||||||
|
[self projectName], categoryPath);
|
||||||
|
|
||||||
listEntry = [[categoryPath componentsSeparatedByString:@"/"] lastObject];
|
listEntry = [[categoryPath componentsSeparatedByString:@"/"] lastObject];
|
||||||
if ([rootCategories containsObject:listEntry]
|
if ([rootCategories containsObject:listEntry])
|
||||||
|| [[projectDict objectForKey:PCSubprojects] containsObject:listEntry])
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
category = [projectBrowser nameOfSelectedCategory];
|
||||||
|
categoryKey = [self keyForCategory:category];
|
||||||
|
if ([categoryKey isEqualToString:PCSubprojects]
|
||||||
|
&& [[projectDict objectForKey:PCSubprojects] containsObject:listEntry])
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -1252,8 +1283,10 @@ NSString
|
||||||
if ([key isEqualToString:PCSubprojects])
|
if ([key isEqualToString:PCSubprojects])
|
||||||
{
|
{
|
||||||
// /Subprojects/Name/Classes/Class.m, should return Classes
|
// /Subprojects/Name/Classes/Class.m, should return Classes
|
||||||
// 0 1 2 3 4
|
// 0 1 2 3 4
|
||||||
// ("",Subprojects,Name,Classes,Class.m)
|
// ("",Subprojects,Name,Classes,Class.m)
|
||||||
|
// 0 1 2 3 4
|
||||||
|
// ("",Subprojects,Name,Subprojects,Name)
|
||||||
if ([pathComponents count] > 4 && activeSubproject)
|
if ([pathComponents count] > 4 && activeSubproject)
|
||||||
{
|
{
|
||||||
i = [pathComponents count] - 1;
|
i = [pathComponents count] - 1;
|
||||||
|
@ -1272,10 +1305,10 @@ NSString
|
||||||
return category;
|
return category;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)keyForCategoryPath:(NSString *)categoryPath
|
- (NSString *)keyForRootCategoryInCategoryPath:(NSString *)categoryPath
|
||||||
{
|
{
|
||||||
NSString *category = nil;
|
NSString *category = nil;
|
||||||
NSString *key = nil;
|
NSString *key = nil;
|
||||||
|
|
||||||
if (categoryPath == nil
|
if (categoryPath == nil
|
||||||
|| [categoryPath isEqualToString:@""]
|
|| [categoryPath isEqualToString:@""]
|
||||||
|
@ -1284,14 +1317,19 @@ NSString
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
category = [self categoryForCategoryPath:categoryPath];
|
category = [self rootCategoryForCategoryPath:categoryPath];
|
||||||
key = [self keyForCategory:category];
|
key = [self keyForCategory:category];
|
||||||
|
|
||||||
PCLogInfo(self, @"{%@}(keyForCategoryPath): %@ key:%@",
|
PCLogInfo(self, @"{%@}(keyForRootCategoryInCategoryPath): %@ key:%@",
|
||||||
projectName, category, key);
|
projectName, categoryPath, key);
|
||||||
|
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString *)keyForCategoryPath:(NSString *)categoryPath
|
||||||
|
{
|
||||||
|
return [self keyForCategory:[self categoryForCategoryPath:categoryPath]];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -50,11 +50,16 @@ extern NSString *PCBrowserDidSetPathNotification;
|
||||||
- (NSView *)view;
|
- (NSView *)view;
|
||||||
|
|
||||||
- (NSString *)nameOfSelectedFile;
|
- (NSString *)nameOfSelectedFile;
|
||||||
- (NSString *)pathOfSelectedFile;
|
- (NSString *)pathToSelectedFile;
|
||||||
|
- (NSString *)nameOfSelectedCategory;
|
||||||
|
- (NSString *)pathToSelectedCategory;
|
||||||
|
- (NSString *)nameOfSelectedRootCategory;
|
||||||
|
|
||||||
- (NSArray *)selectedFiles;
|
- (NSArray *)selectedFiles;
|
||||||
|
|
||||||
|
- (NSString *)path;
|
||||||
- (BOOL)setPath:(NSString *)path;
|
- (BOOL)setPath:(NSString *)path;
|
||||||
- (BOOL)setPathForFile:(NSString *)file category:(NSString *)category;
|
- (void)reloadLastColumn;
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// ==== Actions
|
// ==== Actions
|
||||||
|
@ -71,7 +76,8 @@ extern NSString *PCBrowserDidSetPathNotification;
|
||||||
|
|
||||||
@interface PCProjectBrowser (ProjectBrowserDelegate)
|
@interface PCProjectBrowser (ProjectBrowserDelegate)
|
||||||
|
|
||||||
- (void)browser:(NSBrowser *)sender createRowsForColumn:(int)column inMatrix:(NSMatrix *)matrix;
|
- (void)browser:(NSBrowser *)sender createRowsForColumn:(int)column
|
||||||
|
inMatrix:(NSMatrix *)matrix;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,8 @@
|
||||||
#include "PCFileManager.h"
|
#include "PCFileManager.h"
|
||||||
#include "PCProjectManager.h"
|
#include "PCProjectManager.h"
|
||||||
#include "PCProject.h"
|
#include "PCProject.h"
|
||||||
#include "PCProjectEditor.h"
|
|
||||||
#include "PCProjectBrowser.h"
|
#include "PCProjectBrowser.h"
|
||||||
|
#include "PCProjectEditor.h"
|
||||||
|
|
||||||
#include "PCLogController.h"
|
#include "PCLogController.h"
|
||||||
|
|
||||||
|
@ -62,8 +62,7 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification";
|
||||||
addObserver:self
|
addObserver:self
|
||||||
selector:@selector(projectDictDidChange:)
|
selector:@selector(projectDictDidChange:)
|
||||||
name:PCProjectDictDidChangeNotification
|
name:PCProjectDictDidChangeNotification
|
||||||
object:project];
|
object:nil];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -88,22 +87,109 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification";
|
||||||
return browser;
|
return browser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns nil if multiple files selected
|
||||||
- (NSString *)nameOfSelectedFile
|
- (NSString *)nameOfSelectedFile
|
||||||
{
|
{
|
||||||
NSString *name = nil;
|
NSString *name = nil;
|
||||||
|
|
||||||
// Doesn't work with subprojects!
|
if ([[browser selectedCells] count] == 1)
|
||||||
if ([browser selectedColumn] != 0 && [[browser selectedCells] count] == 1)
|
|
||||||
{
|
{
|
||||||
name = [[[browser path] componentsSeparatedByString:@"/"] lastObject];
|
name = [[browser path] lastPathComponent];
|
||||||
|
if ([name isEqualToString:[self nameOfSelectedCategory]])
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns nil if multiple files selected
|
||||||
|
- (NSString *)pathToSelectedFile
|
||||||
|
{
|
||||||
|
NSString *name = nil;
|
||||||
|
NSString *path = nil;
|
||||||
|
|
||||||
|
if ([[browser selectedCells] count] == 1)
|
||||||
|
{
|
||||||
|
name = [[browser path] lastPathComponent];
|
||||||
|
if ([name isEqualToString:[self nameOfSelectedCategory]])
|
||||||
|
{
|
||||||
|
path = nil;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
path = [browser path];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns nil of multiple categories selected
|
||||||
|
- (NSString *)nameOfSelectedCategory
|
||||||
|
{
|
||||||
|
NSString *name = nil;
|
||||||
|
NSArray *pathArray = [[browser path] componentsSeparatedByString:@"/"];
|
||||||
|
PCProject *activeProject = [[project projectManager] activeProject];
|
||||||
|
NSArray *rootCategories = [activeProject rootCategories];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if ([rootCategories containsObject:[pathArray lastObject]]
|
||||||
|
&& [[browser selectedCells] count] > 1)
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = [pathArray count] - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
if ([rootCategories containsObject:[pathArray objectAtIndex:i]])
|
||||||
|
{
|
||||||
|
name = [pathArray objectAtIndex:i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)pathOfSelectedFile
|
// Returns nil of multiple categories selected
|
||||||
|
- (NSString *)pathToSelectedCategory
|
||||||
{
|
{
|
||||||
return [browser path];
|
NSString *path = nil;
|
||||||
|
NSString *selectedCategory = [self nameOfSelectedCategory];
|
||||||
|
NSMutableArray *bPathArray = nil;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (selectedCategory)
|
||||||
|
{
|
||||||
|
bPathArray = [NSMutableArray arrayWithArray:[[browser path]
|
||||||
|
componentsSeparatedByString:@"/"]];
|
||||||
|
i = [bPathArray count] - 1;
|
||||||
|
while (![[bPathArray objectAtIndex:i] isEqualToString:selectedCategory])
|
||||||
|
{
|
||||||
|
[bPathArray removeObjectAtIndex:i];
|
||||||
|
i = [bPathArray count] - 1;
|
||||||
|
}
|
||||||
|
path = [bPathArray componentsJoinedByString:@"/"];
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *)nameOfSelectedRootCategory
|
||||||
|
{
|
||||||
|
NSString *categoryPath = [self pathToSelectedCategory];
|
||||||
|
NSArray *pathComponents = nil;
|
||||||
|
|
||||||
|
if ([categoryPath isEqualToString:@"/"] || [categoryPath isEqualToString:@""])
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
pathComponents = [categoryPath componentsSeparatedByString:@"/"];
|
||||||
|
|
||||||
|
return [pathComponents objectAtIndex:1];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *)selectedFiles
|
- (NSArray *)selectedFiles
|
||||||
|
@ -112,39 +198,34 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification";
|
||||||
NSMutableArray *files = [[NSMutableArray alloc] initWithCapacity: 1];
|
NSMutableArray *files = [[NSMutableArray alloc] initWithCapacity: 1];
|
||||||
int i;
|
int i;
|
||||||
int count = [cells count];
|
int count = [cells count];
|
||||||
|
PCProject *activeProject = [[project projectManager] activeProject];
|
||||||
|
|
||||||
|
// Return nil if categories selected
|
||||||
|
if ([cells count] == 0
|
||||||
|
|| [[activeProject rootCategories]
|
||||||
|
containsObject:[[cells objectAtIndex:0] stringValue]])
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
[files addObject: [[cells objectAtIndex: i] stringValue]];
|
[files addObject: [[cells objectAtIndex: i] stringValue]];
|
||||||
}
|
}
|
||||||
|
|
||||||
return (NSArray *)files;
|
return (NSArray *)files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString *)path
|
||||||
|
{
|
||||||
|
return [browser path];
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL)setPath:(NSString *)path
|
- (BOOL)setPath:(NSString *)path
|
||||||
{
|
{
|
||||||
int selectedColumn;
|
int selectedColumn;
|
||||||
NSMatrix *columnMatrix = nil;
|
NSMatrix *columnMatrix = nil;
|
||||||
|
BOOL res;
|
||||||
while ((selectedColumn = [browser selectedColumn]) >= 0)
|
|
||||||
{
|
|
||||||
columnMatrix = [browser matrixInColumn:selectedColumn];
|
|
||||||
[columnMatrix deselectAllCells];
|
|
||||||
}
|
|
||||||
|
|
||||||
PCLogInfo(self, @"[setPath]: %@", path);
|
|
||||||
|
|
||||||
return [browser setPath:path];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)setPathForFile:(NSString *)file category:(NSString *)category
|
|
||||||
{
|
|
||||||
NSArray *comp = [NSArray arrayWithObjects: @"/",category,@"/",file,nil];
|
|
||||||
NSString *path = [NSString pathWithComponents:comp];
|
|
||||||
BOOL result;
|
|
||||||
|
|
||||||
int selectedColumn;
|
|
||||||
NSMatrix *columnMatrix = nil;
|
|
||||||
|
|
||||||
if ([[browser path] isEqualToString: path])
|
if ([[browser path] isEqualToString: path])
|
||||||
{
|
{
|
||||||
|
@ -159,15 +240,40 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification";
|
||||||
}
|
}
|
||||||
// End of HACK
|
// End of HACK
|
||||||
|
|
||||||
result = [browser setPath:path];
|
PCLogInfo(self, @"[setPath]: %@", path);
|
||||||
|
|
||||||
[self click:browser];
|
res = [browser setPath:path];
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter]
|
||||||
|
postNotificationName:PCBrowserDidSetPathNotification
|
||||||
|
object:self];
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)reloadLastColumn
|
||||||
|
{
|
||||||
|
int column = [browser lastColumn];
|
||||||
|
NSString *category = [self nameOfSelectedCategory];
|
||||||
|
int selectedColumn = [browser selectedColumn];
|
||||||
|
NSMatrix *colMatrix = [browser matrixInColumn:selectedColumn];
|
||||||
|
int rowCount = 0, colCount = 0, spCount = 0;
|
||||||
|
PCProject *activeProject = [[project projectManager] activeProject];
|
||||||
|
|
||||||
|
[colMatrix getNumberOfRows:&rowCount columns:&colCount];
|
||||||
|
spCount = [[[activeProject projectDict] objectForKey:PCSubprojects] count];
|
||||||
|
|
||||||
|
if ([category isEqualToString:@"Subprojects"] && rowCount != spCount
|
||||||
|
&& ![[[browser selectedCell] stringValue] isEqualToString:@"Subprojects"])
|
||||||
|
{
|
||||||
|
column = selectedColumn;
|
||||||
|
}
|
||||||
|
|
||||||
/* [[NSNotificationCenter defaultCenter]
|
[browser reloadColumn:column];
|
||||||
postNotificationName:PCBrowserDidSetPathNotification
|
|
||||||
object:self];*/
|
|
||||||
|
|
||||||
return result;
|
[[NSNotificationCenter defaultCenter]
|
||||||
|
postNotificationName:PCBrowserDidSetPathNotification
|
||||||
|
object:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
@ -176,38 +282,33 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification";
|
||||||
|
|
||||||
- (void)click:(id)sender
|
- (void)click:(id)sender
|
||||||
{
|
{
|
||||||
|
NSUserDefaults *ud = nil;
|
||||||
NSString *category = nil;
|
NSString *category = nil;
|
||||||
NSString *fileName = nil;
|
NSString *fileName = nil;
|
||||||
PCProject *sp = nil;
|
|
||||||
NSString *filePath = nil;
|
NSString *filePath = nil;
|
||||||
NSUserDefaults *ud = nil;
|
NSString *key = nil;
|
||||||
|
PCProject *activeProject = nil;
|
||||||
|
|
||||||
if (sender != browser)
|
if (sender != browser)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([[sender selectedCell] isLeaf] && [[self selectedFiles] count] == 1)
|
if ([[sender selectedCell] isLeaf] && [[self selectedFiles] count] == 1)
|
||||||
{
|
{
|
||||||
ud = [NSUserDefaults standardUserDefaults];
|
ud = [NSUserDefaults standardUserDefaults];
|
||||||
category = [project categoryForCategoryPath:[browser path]];
|
category = [self nameOfSelectedCategory];
|
||||||
fileName = [[sender selectedCell] stringValue];
|
fileName = [[sender selectedCell] stringValue];
|
||||||
if ((sp = [project activeSubproject]) != nil)
|
|
||||||
{
|
activeProject = [[project projectManager] activeProject];
|
||||||
filePath = [[sp projectPath]
|
key = [activeProject keyForCategory:category];
|
||||||
stringByAppendingPathComponent:fileName];
|
filePath = [activeProject dirForCategoryKey:key];
|
||||||
}
|
filePath = [filePath stringByAppendingPathComponent:fileName];
|
||||||
else
|
|
||||||
{
|
|
||||||
filePath = [[project projectPath]
|
|
||||||
stringByAppendingPathComponent:fileName];
|
|
||||||
}
|
|
||||||
|
|
||||||
PCLogInfo(self, @"[click] category: %@ filePath: %@",
|
PCLogInfo(self, @"[click] category: %@ filePath: %@",
|
||||||
category, filePath);
|
category, filePath);
|
||||||
|
|
||||||
if ([project isEditableCategory:category]
|
if ([activeProject isEditableCategory:category])
|
||||||
|| [sp isEditableCategory:category])
|
|
||||||
{
|
{
|
||||||
if (![[ud objectForKey:SeparateEditor] isEqualToString:@"YES"])
|
if (![[ud objectForKey:SeparateEditor] isEqualToString:@"YES"])
|
||||||
{
|
{
|
||||||
|
@ -218,6 +319,11 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PCLogStatus(self, @"nameOfSelectedCategory: %@",
|
||||||
|
[self nameOfSelectedCategory]);
|
||||||
|
PCLogStatus(self, @"nameOfSelectedFile: %@",
|
||||||
|
[self nameOfSelectedFile]);
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter]
|
[[NSNotificationCenter defaultCenter]
|
||||||
postNotificationName:PCBrowserDidSetPathNotification
|
postNotificationName:PCBrowserDidSetPathNotification
|
||||||
object:self];
|
object:self];
|
||||||
|
@ -225,32 +331,31 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification";
|
||||||
|
|
||||||
- (void)doubleClick:(id)sender
|
- (void)doubleClick:(id)sender
|
||||||
{
|
{
|
||||||
|
id selectedCell;
|
||||||
|
|
||||||
if (sender != browser)
|
if (sender != browser)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([[sender selectedCell] isLeaf])
|
selectedCell = [sender selectedCell];
|
||||||
|
|
||||||
|
if ([selectedCell isLeaf])
|
||||||
{
|
{
|
||||||
NSString *category = [project categoryForCategoryPath:[browser path]];
|
NSString *category = [self nameOfSelectedCategory];
|
||||||
NSString *fileName = [[sender selectedCell] stringValue];
|
NSString *fileName = [[sender selectedCell] stringValue];
|
||||||
PCProject *sp = nil;
|
|
||||||
NSString *filePath = nil;
|
NSString *filePath = nil;
|
||||||
|
NSString *key = nil;
|
||||||
|
PCProject *activeProject = nil;
|
||||||
|
|
||||||
|
activeProject = [[project projectManager] activeProject];
|
||||||
|
key = [activeProject keyForCategory:category];
|
||||||
|
filePath = [activeProject dirForCategoryKey:key];
|
||||||
|
filePath = [filePath stringByAppendingPathComponent:fileName];
|
||||||
|
|
||||||
if ((sp = [project activeSubproject]) != nil)
|
PCLogInfo(self, @"{doubleClick} filePath: %@", filePath);
|
||||||
{
|
|
||||||
filePath = [sp dirForCategoryKey:[sp keyForCategory:category]];
|
|
||||||
filePath = [filePath stringByAppendingPathComponent:fileName];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
filePath = [project dirForCategoryKey:
|
|
||||||
[project keyForCategory:category]];
|
|
||||||
filePath = [filePath stringByAppendingPathComponent:fileName];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ([project isEditableCategory:category]
|
if ([activeProject isEditableCategory:category])
|
||||||
|| [sp isEditableCategory:category])
|
|
||||||
{
|
{
|
||||||
[[project projectEditor] editorForFile:filePath
|
[[project projectEditor] editorForFile:filePath
|
||||||
categoryPath:[browser path]
|
categoryPath:[browser path]
|
||||||
|
@ -265,7 +370,14 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[[project projectManager] addProjectFiles];
|
if ([[selectedCell title] isEqualToString:@"Subprojects"])
|
||||||
|
{
|
||||||
|
[[project projectManager] addSubproject];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[[project projectManager] addProjectFiles];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,23 +387,20 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification";
|
||||||
|
|
||||||
- (void)projectDictDidChange:(NSNotification *)aNotif
|
- (void)projectDictDidChange:(NSNotification *)aNotif
|
||||||
{
|
{
|
||||||
if (browser &&
|
PCProject *changedProject = nil;
|
||||||
([aNotif object] == project
|
PCProject *activeProject = nil;
|
||||||
|| [[project loadedSubprojects] containsObject:[aNotif object]]))
|
|
||||||
{
|
|
||||||
NSString *browserPath = [browser path];
|
|
||||||
NSString *slctdCategory = [project selectedRootCategory];
|
|
||||||
|
|
||||||
if (slctdCategory && browserPath && ![browserPath isEqualToString:@"/"])
|
|
||||||
{
|
|
||||||
if ([[[project projectEditor] allEditors] count] == 0
|
|
||||||
&& [project isEditableCategory:slctdCategory])
|
|
||||||
{
|
|
||||||
[self setPathForFile:nil category:slctdCategory];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[browser reloadColumn:[browser lastColumn]];
|
if (!browser)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
changedProject = [aNotif object];
|
||||||
|
activeProject = [[project projectManager] activeProject];
|
||||||
|
|
||||||
|
if (changedProject == project || changedProject == activeProject)
|
||||||
|
{
|
||||||
|
[self reloadLastColumn];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,21 +408,25 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification";
|
||||||
|
|
||||||
@implementation PCProjectBrowser (ProjectBrowserDelegate)
|
@implementation PCProjectBrowser (ProjectBrowserDelegate)
|
||||||
|
|
||||||
- (void)browser:(NSBrowser *)sender createRowsForColumn:(int)column inMatrix:(NSMatrix *)matrix
|
- (void)browser:(NSBrowser *)sender createRowsForColumn:(int)column
|
||||||
|
inMatrix:(NSMatrix *)matrix
|
||||||
{
|
{
|
||||||
NSString *pathToCol = nil;
|
NSString *pathToCol = nil;
|
||||||
NSArray *files = nil;
|
NSArray *files = nil;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
if (sender != browser || !matrix ||![matrix isKindOfClass:[NSMatrix class]])
|
if (sender != browser || !matrix || ![matrix isKindOfClass:[NSMatrix class]])
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pathToCol = [sender pathToColumn:column];
|
pathToCol = [sender pathToColumn:column];
|
||||||
files = [project contentAtCategoryPath:pathToCol];
|
files = [project contentAtCategoryPath:pathToCol];
|
||||||
count = [files count];
|
if (files)
|
||||||
|
{
|
||||||
|
count = [files count];
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < count; ++i)
|
for (i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -252,7 +252,9 @@ NSString *PCEditorDidResignActiveNotification =
|
||||||
- (void)orderFrontEditorForFile:(NSString *)path
|
- (void)orderFrontEditorForFile:(NSString *)path
|
||||||
{
|
{
|
||||||
PCEditor *editor = [editorsDict objectForKey:path];
|
PCEditor *editor = [editorsDict objectForKey:path];
|
||||||
|
|
||||||
|
NSLog(@"PCProjectEditor: orderFrontEditorForFile");
|
||||||
|
|
||||||
if ([editor isWindowed])
|
if ([editor isWindowed])
|
||||||
{
|
{
|
||||||
[editor show];
|
[editor show];
|
||||||
|
@ -463,12 +465,12 @@ NSString *PCEditorDidResignActiveNotification =
|
||||||
|
|
||||||
lastEditorKey = [[editorsDict allKeys] lastObject];
|
lastEditorKey = [[editorsDict allKeys] lastObject];
|
||||||
[componentView setContentView:[lastEditor componentView]];
|
[componentView setContentView:[lastEditor componentView]];
|
||||||
[[project projectWindow] makeFirstResponder:[lastEditor editorView]];
|
// [[project projectWindow] makeFirstResponder:[lastEditor editorView]];
|
||||||
[self setActiveEditor:lastEditor];
|
[self setActiveEditor:lastEditor];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[[project projectWindow] makeFirstResponder:scrollView];
|
// [[project projectWindow] makeFirstResponder:scrollView];
|
||||||
[componentView setContentView:scrollView];
|
[componentView setContentView:scrollView];
|
||||||
[self setActiveEditor:nil];
|
[self setActiveEditor:nil];
|
||||||
}
|
}
|
||||||
|
@ -478,8 +480,11 @@ NSString *PCEditorDidResignActiveNotification =
|
||||||
{
|
{
|
||||||
PCEditor *editor = [aNotif object];
|
PCEditor *editor = [aNotif object];
|
||||||
NSString *categoryPath = nil;
|
NSString *categoryPath = nil;
|
||||||
|
|
||||||
if ([editorsDict objectForKey:[editor path]] != editor)
|
NSLog(@"PCPE: editorDidBecomeActive: %@", [editor path]);
|
||||||
|
|
||||||
|
if ([editorsDict objectForKey:[editor path]] != editor
|
||||||
|
|| activeEditor == editor)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -497,6 +502,7 @@ NSString *PCEditorDidResignActiveNotification =
|
||||||
|
|
||||||
- (void)editorDidResignActive:(NSNotification *)aNotif
|
- (void)editorDidResignActive:(NSNotification *)aNotif
|
||||||
{
|
{
|
||||||
|
[self setActiveEditor:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -724,8 +724,8 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PCLogInfo(self, @"file name changed from: %@ to: %@",
|
PCLogInfo(self, @"{%@} file name changed from: %@ to: %@",
|
||||||
fileName, [fileNameField stringValue]);
|
[project projectName], fileName, [fileNameField stringValue]);
|
||||||
|
|
||||||
if ([project renameFile:fileName toFile:[fileNameField stringValue]] == NO)
|
if ([project renameFile:fileName toFile:[fileNameField stringValue]] == NO)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
{
|
{
|
||||||
NSAssert(aProj, @"Project is mandatory!");
|
NSAssert(aProj, @"Project is mandatory!");
|
||||||
|
|
||||||
|
NSLog(@"PCProjectLoadedFiles: init");
|
||||||
|
|
||||||
if ((self = [super init]))
|
if ((self = [super init]))
|
||||||
{
|
{
|
||||||
project = aProj;
|
project = aProj;
|
||||||
|
@ -186,8 +188,8 @@
|
||||||
|
|
||||||
- (void)click:(id)sender
|
- (void)click:(id)sender
|
||||||
{
|
{
|
||||||
int row = [filesList selectedRow];
|
int row = [filesList selectedRow];
|
||||||
NSString *path = [[self editedFilesRep] objectAtIndex:row];
|
NSString *path = [[self editedFilesRep] objectAtIndex:row];
|
||||||
|
|
||||||
[[project projectEditor] orderFrontEditorForFile:path];
|
[[project projectEditor] orderFrontEditorForFile:path];
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,18 +233,13 @@ extern NSString *PCActiveProjectDidChangeNotification;
|
||||||
|
|
||||||
@interface PCProjectManager (Subprojects)
|
@interface PCProjectManager (Subprojects)
|
||||||
|
|
||||||
// --- New
|
|
||||||
- (BOOL)newSubproject;
|
- (BOOL)newSubproject;
|
||||||
|
- (BOOL)addSubproject;
|
||||||
- (void)closeNewSubprojectPanel:(id)sender;
|
- (void)closeNewSubprojectPanel:(id)sender;
|
||||||
- (BOOL)createSubproject:(id)sender;
|
- (BOOL)createSubproject:(id)sender;
|
||||||
|
- (PCProject *)createSubprojectOfType:(NSString *)projectType
|
||||||
|
path:(NSString *)aPath;
|
||||||
- (BOOL)createSubproject;
|
- (BOOL)createSubproject;
|
||||||
|
|
||||||
// --- Add
|
|
||||||
- (BOOL)addSubprojectAt:(NSString *)path;
|
|
||||||
|
|
||||||
// --- Remove
|
|
||||||
- (void)removeSubproject;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -60,6 +60,11 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
{
|
{
|
||||||
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
|
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
|
||||||
|
|
||||||
|
buildPanel = nil;
|
||||||
|
launchPanel = nil;
|
||||||
|
loadedFilesPanel = nil;
|
||||||
|
findPanel = nil;
|
||||||
|
|
||||||
[self loadProjectTypeBunldes];
|
[self loadProjectTypeBunldes];
|
||||||
|
|
||||||
loadedProjects = [[NSMutableDictionary alloc] init];
|
loadedProjects = [[NSMutableDictionary alloc] init];
|
||||||
|
@ -240,9 +245,13 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
|
|
||||||
- (NSPanel *)loadedFilesPanel
|
- (NSPanel *)loadedFilesPanel
|
||||||
{
|
{
|
||||||
if (!loadedFilesPanel)
|
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||||
|
|
||||||
|
if (!loadedFilesPanel
|
||||||
|
&& [[ud objectForKey:SeparateLoadedFiles] isEqualToString:@"YES"])
|
||||||
{
|
{
|
||||||
loadedFilesPanel = [[PCLoadedFilesPanel alloc] initWithProjectManager:self];
|
loadedFilesPanel =
|
||||||
|
[[PCLoadedFilesPanel alloc] initWithProjectManager:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
return loadedFilesPanel;
|
return loadedFilesPanel;
|
||||||
|
@ -259,7 +268,10 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
|
|
||||||
- (NSPanel *)buildPanel
|
- (NSPanel *)buildPanel
|
||||||
{
|
{
|
||||||
if (!buildPanel)
|
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||||
|
|
||||||
|
if (!buildPanel
|
||||||
|
&& [[ud objectForKey:SeparateBuilder] isEqualToString:@"YES"])
|
||||||
{
|
{
|
||||||
buildPanel = [[PCBuildPanel alloc] initWithProjectManager:self];
|
buildPanel = [[PCBuildPanel alloc] initWithProjectManager:self];
|
||||||
}
|
}
|
||||||
|
@ -269,7 +281,10 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
|
|
||||||
- (NSPanel *)launchPanel
|
- (NSPanel *)launchPanel
|
||||||
{
|
{
|
||||||
if (!launchPanel)
|
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||||
|
|
||||||
|
if (!launchPanel
|
||||||
|
&& [[ud objectForKey:SeparateLauncher] isEqualToString:@"YES"])
|
||||||
{
|
{
|
||||||
launchPanel = [[PCLaunchPanel alloc] initWithProjectManager:self];
|
launchPanel = [[PCLaunchPanel alloc] initWithProjectManager:self];
|
||||||
}
|
}
|
||||||
|
@ -419,7 +434,9 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
{
|
{
|
||||||
PCLogStatus(self, @"Project %@ loaded as %@",
|
PCLogStatus(self, @"Project %@ loaded as %@",
|
||||||
[project projectName], [projectCreator projectTypeName]);
|
[project projectName], [projectCreator projectTypeName]);
|
||||||
|
// Started only if there's not save timer yet
|
||||||
[self startSaveTimer];
|
[self startSaveTimer];
|
||||||
|
[project validateProjectDict];
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,25 +473,24 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
[project setProjectManager:self];
|
|
||||||
[project validateProjectDict];
|
|
||||||
[loadedProjects setObject:project forKey:projectName];
|
[loadedProjects setObject:project forKey:projectName];
|
||||||
[self setActiveProject:project];
|
[self setActiveProject:project];
|
||||||
|
[project setProjectManager:self];
|
||||||
|
|
||||||
// Windows and panels
|
// Windows and panels
|
||||||
wap = [[NSDictionary dictionaryWithContentsOfFile:aPath]
|
wap = [[NSDictionary dictionaryWithContentsOfFile:aPath]
|
||||||
objectForKey:@"PC_WINDOWS"];
|
objectForKey:@"PC_WINDOWS"];
|
||||||
if ([[wap allKeys] containsObject:@"ProjectBuild"])
|
if ([[wap allKeys] containsObject:@"ProjectBuild"])
|
||||||
{
|
{
|
||||||
[[self buildPanel] orderFront:self];
|
[[project projectWindow] showProjectBuild:self];
|
||||||
}
|
}
|
||||||
if ([[wap allKeys] containsObject:@"ProjectLaunch"])
|
if ([[wap allKeys] containsObject:@"ProjectLaunch"])
|
||||||
{
|
{
|
||||||
[[self launchPanel] orderFront:self];
|
[[project projectWindow] showProjectLaunch:self];
|
||||||
}
|
}
|
||||||
if ([[wap allKeys] containsObject:@"LoadedFiles"])
|
if ([[wap allKeys] containsObject:@"LoadedFiles"])
|
||||||
{
|
{
|
||||||
[[self loadedFilesPanel] orderFront:self];
|
[[project projectWindow] showProjectLoadedFiles:self];
|
||||||
}
|
}
|
||||||
[[project projectWindow] orderFront:self];
|
[[project projectWindow] orderFront:self];
|
||||||
|
|
||||||
|
@ -591,16 +607,15 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
|
|
||||||
- (BOOL)addProjectFiles
|
- (BOOL)addProjectFiles
|
||||||
{
|
{
|
||||||
NSString *categoryKey = nil;
|
PCProject *project = [self rootActiveProject];
|
||||||
NSArray *fileTypes = nil;
|
NSString *category = [[project projectBrowser] nameOfSelectedCategory];
|
||||||
|
NSString *categoryKey = [activeProject keyForCategory:category];
|
||||||
NSMutableArray *files = nil;
|
NSMutableArray *files = nil;
|
||||||
|
|
||||||
categoryKey = [activeProject selectedRootCategoryKey];
|
|
||||||
fileTypes = [activeProject fileTypesForCategoryKey:categoryKey];
|
|
||||||
|
|
||||||
files = [fileManager filesForAdd];
|
files = [fileManager filesForAdd];
|
||||||
|
|
||||||
PCLogInfo(self, @"[addProjectFiles] %@", files);
|
PCLogInfo(self, @"[addProjectFiles] %@ to category: %@ of project %@",
|
||||||
|
files, categoryKey, [activeProject projectName]);
|
||||||
|
|
||||||
// No files was selected
|
// No files was selected
|
||||||
if (!files)
|
if (!files)
|
||||||
|
@ -621,44 +636,24 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
|
|
||||||
- (BOOL)removeProjectFiles
|
- (BOOL)removeProjectFiles
|
||||||
{
|
{
|
||||||
NSArray *files = nil;
|
PCProject *project = [self rootActiveProject];
|
||||||
NSString *categoryKey = nil;
|
NSArray *files = [[project projectBrowser] selectedFiles];
|
||||||
NSString *directory = nil;
|
NSString *category = [[project projectBrowser] nameOfSelectedCategory];
|
||||||
NSString *bPath = nil;
|
NSString *categoryKey = [project keyForCategory:category];
|
||||||
PCProject *project = activeProject;
|
NSString *directory = [activeProject dirForCategoryKey:categoryKey];
|
||||||
NSString *removeString = [NSString stringWithString:@"Remove files..."];
|
NSString *removeString = [NSString stringWithString:@"Remove files..."];
|
||||||
NSMutableArray *subprojs = nil;
|
NSMutableArray *subprojs = [NSMutableArray array];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!activeProject)
|
|
||||||
{
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We need to get root project
|
|
||||||
while ([project isSubproject])
|
|
||||||
{
|
|
||||||
project = [project superProject];
|
|
||||||
}
|
|
||||||
bPath = [[activeProject projectBrowser] pathOfSelectedFile];
|
|
||||||
categoryKey = [project keyForCategoryPath:bPath];
|
|
||||||
|
|
||||||
files = [[activeProject projectBrowser] selectedFiles];
|
|
||||||
directory = [activeProject dirForCategoryKey:categoryKey];
|
|
||||||
|
|
||||||
// Determining target project
|
// Determining target project
|
||||||
if ([categoryKey isEqualToString:PCSubprojects]
|
if ([categoryKey isEqualToString:PCSubprojects])
|
||||||
&& [activeProject isSubproject])
|
|
||||||
{
|
{
|
||||||
subprojs = [NSMutableArray array];
|
if ([activeProject isSubproject])
|
||||||
project = [activeProject superProject];
|
|
||||||
removeString = [NSString stringWithString:@"Remove subprojects..."];
|
|
||||||
for (i = 0; i < [files count]; i++)
|
|
||||||
{
|
{
|
||||||
[subprojs addObject:
|
project = [activeProject superProject];
|
||||||
[[files objectAtIndex:i]
|
[self setActiveProject:project];
|
||||||
stringByAppendingPathExtension:@"subproj"]];
|
|
||||||
}
|
}
|
||||||
|
removeString = [NSString stringWithString:@"Remove subprojects..."];
|
||||||
directory = [project dirForCategoryKey:categoryKey];
|
directory = [project dirForCategoryKey:categoryKey];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -667,13 +662,12 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
}
|
}
|
||||||
|
|
||||||
PCLogInfo(self, @"%@: %@ from %@", removeString, files, directory);
|
PCLogInfo(self, @"%@: %@ from %@", removeString, files, directory);
|
||||||
PCLogInfo(self, @"[removeProjectFiles]:%@ KEY:%@ bPath:%@",
|
PCLogInfo(self, @"[removeProjectFiles]:%@ KEY:%@",
|
||||||
[activeProject projectName], categoryKey, bPath);
|
[activeProject projectName], categoryKey);
|
||||||
|
|
||||||
if (files)
|
if (files)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
NSMutableArray *bPathArray = nil;
|
|
||||||
|
|
||||||
if ([categoryKey isEqualToString:PCLibraries])
|
if ([categoryKey isEqualToString:PCLibraries])
|
||||||
{
|
{
|
||||||
|
@ -696,20 +690,24 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
{
|
{
|
||||||
BOOL flag = (ret == NSAlertDefaultReturn) ? YES : NO;
|
BOOL flag = (ret == NSAlertDefaultReturn) ? YES : NO;
|
||||||
|
|
||||||
|
// Remove from projectDict
|
||||||
ret = [project removeFiles:files forKey:categoryKey];
|
ret = [project removeFiles:files forKey:categoryKey];
|
||||||
|
|
||||||
|
// Remove files from disk
|
||||||
if (flag && ret && ![categoryKey isEqualToString:PCLibraries])
|
if (flag && ret && ![categoryKey isEqualToString:PCLibraries])
|
||||||
{
|
{
|
||||||
if ([categoryKey isEqualToString:PCSubprojects])
|
if ([categoryKey isEqualToString:PCSubprojects])
|
||||||
{
|
{
|
||||||
ret = [fileManager removeFiles:subprojs
|
for (i = 0; i < [files count]; i++)
|
||||||
fromDirectory:directory];
|
{
|
||||||
}
|
[subprojs addObject:
|
||||||
else
|
[[files objectAtIndex:i]
|
||||||
{
|
stringByAppendingPathExtension:@"subproj"]];
|
||||||
ret = [fileManager removeFiles:files
|
}
|
||||||
fromDirectory:directory];
|
files = subprojs;
|
||||||
}
|
}
|
||||||
|
ret = [fileManager removeFiles:files
|
||||||
|
fromDirectory:directory];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
|
@ -719,24 +717,12 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
@"OK", nil, nil, [activeProject projectName]);
|
@"OK", nil, nil, [activeProject projectName]);
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save project because we've removed file(s) from disk
|
|
||||||
// Should be fixed later (add pending removal of files?)
|
|
||||||
else if (flag)
|
else if (flag)
|
||||||
{
|
{
|
||||||
[project save];
|
// Save project because we've removed file(s) from disk
|
||||||
|
// Should be fixed later (add pending removal of files?)
|
||||||
|
[activeProject save];
|
||||||
}
|
}
|
||||||
bPathArray = [NSMutableArray
|
|
||||||
arrayWithArray:[bPath componentsSeparatedByString:@"/"]];
|
|
||||||
i = [bPathArray count];
|
|
||||||
while ([[bPathArray objectAtIndex:i-1] isEqualToString:@""])
|
|
||||||
{
|
|
||||||
[bPathArray removeObjectAtIndex:i-1];
|
|
||||||
i = [bPathArray count];
|
|
||||||
}
|
|
||||||
[bPathArray removeObjectAtIndex:i-1];
|
|
||||||
[[activeProject projectBrowser]
|
|
||||||
setPath:[bPathArray componentsJoinedByString:@"/"]];
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -980,7 +966,6 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
|
|
||||||
@implementation PCProjectManager (Subprojects)
|
@implementation PCProjectManager (Subprojects)
|
||||||
|
|
||||||
// --- New
|
|
||||||
- (BOOL)newSubproject
|
- (BOOL)newSubproject
|
||||||
{
|
{
|
||||||
PCLogInfo(self, @"newSubproject");
|
PCLogInfo(self, @"newSubproject");
|
||||||
|
@ -1031,7 +1016,6 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
|
|
||||||
- (BOOL)createSubproject
|
- (BOOL)createSubproject
|
||||||
{
|
{
|
||||||
PCProject *superProject = activeProject;
|
|
||||||
PCProject *subproject = nil;
|
PCProject *subproject = nil;
|
||||||
NSString *spName = [nsNameField stringValue];
|
NSString *spName = [nsNameField stringValue];
|
||||||
NSString *spPath = nil;
|
NSString *spPath = nil;
|
||||||
|
@ -1045,20 +1029,50 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
|
|
||||||
spPath = [[activeProject projectPath] stringByAppendingPathComponent:spName];
|
spPath = [[activeProject projectPath] stringByAppendingPathComponent:spName];
|
||||||
|
|
||||||
PCLogInfo(self, @"creating subproject with type %@ at path %@",
|
PCLogStatus(self, @"creating subproject with type %@ at path %@",
|
||||||
spType, spPath);
|
spType, spPath);
|
||||||
|
|
||||||
// Create subproject
|
// Create subproject
|
||||||
subproject = [self createProjectOfType:spType path:spPath];
|
subproject = [self createSubprojectOfType:spType path:spPath];
|
||||||
|
|
||||||
// For now root project can contain subproject but suboproject can't.
|
|
||||||
[subproject setIsSubproject:YES];
|
|
||||||
[subproject setSuperProject:superProject];
|
|
||||||
|
|
||||||
[superProject addSubproject:subproject];
|
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (PCProject *)createSubprojectOfType:(NSString *)projectType
|
||||||
|
path:(NSString *)aPath
|
||||||
|
{
|
||||||
|
NSString *className = [projectTypes objectForKey:projectType];
|
||||||
|
Class creatorClass = NSClassFromString(className);
|
||||||
|
PCProject *subproject = nil;
|
||||||
|
/* NSString *subprojectName = [aPath lastPathComponent];
|
||||||
|
|
||||||
|
if ((project = [activeProject objectForKey:projectName]) != nil)
|
||||||
|
{
|
||||||
|
[[project projectWindow] makeKeyAndOrderFront:self];
|
||||||
|
return project;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
if (![creatorClass conformsToProtocol:@protocol(ProjectType)])
|
||||||
|
{
|
||||||
|
[NSException raise:NOT_A_PROJECT_TYPE_EXCEPTION
|
||||||
|
format:@"%@ does not conform to ProjectType!", projectType];
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(subproject = [[creatorClass sharedCreator] createProjectAt:aPath]))
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
[subproject setIsSubproject:YES];
|
||||||
|
[subproject setSuperProject:activeProject];
|
||||||
|
[subproject setProjectManager:self];
|
||||||
|
|
||||||
|
PCLogInfo(self, @"{createSubproject} add to %@", [activeProject projectName]);
|
||||||
|
[activeProject addSubproject:subproject];
|
||||||
|
|
||||||
|
return subproject;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)controlTextDidChange:(NSNotification *)aNotif
|
- (void)controlTextDidChange:(NSNotification *)aNotif
|
||||||
{
|
{
|
||||||
if ([aNotif object] != nsNameField)
|
if ([aNotif object] != nsNameField)
|
||||||
|
@ -1077,15 +1091,51 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Add
|
- (BOOL)addSubproject
|
||||||
- (BOOL)addSubprojectAt:(NSString *)path
|
|
||||||
{
|
{
|
||||||
return NO;
|
NSFileManager *fm = [NSFileManager defaultManager];
|
||||||
}
|
NSMutableArray *files = nil;
|
||||||
|
NSString *pcProject = nil;
|
||||||
|
NSString *spDir = nil;
|
||||||
|
NSDictionary *spDict = nil;
|
||||||
|
NSString *spName = nil;
|
||||||
|
int i;
|
||||||
|
|
||||||
// --- Remove
|
files = [fileManager filesForAdd];
|
||||||
- (void)removeSubproject
|
|
||||||
{
|
// Validate if it real projects
|
||||||
|
for (i = 0; i < [files count]; i++)
|
||||||
|
{
|
||||||
|
spDir = [files objectAtIndex:i];
|
||||||
|
pcProject = [spDir stringByAppendingPathComponent:@"PC.project"];
|
||||||
|
if (![[spDir pathExtension] isEqualToString:@"subproj"]
|
||||||
|
|| ![fm fileExistsAtPath:pcProject])
|
||||||
|
{
|
||||||
|
[files removeObjectAtIndex:i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PCLogInfo(self, @"{addSubproject} %@", files);
|
||||||
|
|
||||||
|
if (![fileManager copyFiles:files
|
||||||
|
intoDirectory:[activeProject projectPath]])
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < [files count]; i++)
|
||||||
|
{
|
||||||
|
spDir = [files objectAtIndex:i];
|
||||||
|
pcProject = [spDir stringByAppendingPathComponent:@"PC.project"];
|
||||||
|
spDict = [NSDictionary dictionaryWithContentsOfFile:pcProject];
|
||||||
|
spName = [spDict objectForKey:PCProjectName];
|
||||||
|
|
||||||
|
PCLogInfo(self, @"{addSubproject} dir: %@ file: %@", spDir, pcProject);
|
||||||
|
|
||||||
|
[activeProject addSubprojectWithName:spName];
|
||||||
|
}
|
||||||
|
|
||||||
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -168,6 +168,7 @@
|
||||||
*/
|
*/
|
||||||
fileIcon = [[NSImageView alloc] initWithFrame: NSMakeRect (496,0,48,48)];
|
fileIcon = [[NSImageView alloc] initWithFrame: NSMakeRect (496,0,48,48)];
|
||||||
[fileIcon setRefusesFirstResponder:YES];
|
[fileIcon setRefusesFirstResponder:YES];
|
||||||
|
[fileIcon setEditable:NO];
|
||||||
[fileIcon setAutoresizingMask: (NSViewMinXMargin | NSViewMinYMargin)];
|
[fileIcon setAutoresizingMask: (NSViewMinXMargin | NSViewMinYMargin)];
|
||||||
[fileIcon setImage: IMAGE (@"projectSuitcase")];
|
[fileIcon setImage: IMAGE (@"projectSuitcase")];
|
||||||
[toolbarView addSubview: fileIcon];
|
[toolbarView addSubview: fileIcon];
|
||||||
|
@ -354,68 +355,75 @@
|
||||||
- (void)setFileIcon:(NSNotification *)notification
|
- (void)setFileIcon:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
id object = [notification object];
|
id object = [notification object];
|
||||||
NSString *path = nil;
|
NSString *categoryName = nil;
|
||||||
NSArray *pathComponents = nil;
|
NSString *fileName = nil;
|
||||||
NSString *lastComponent = nil;
|
|
||||||
NSString *fileExtension = nil;
|
NSString *fileExtension = nil;
|
||||||
NSString *iconName = nil;
|
NSString *iconName = nil;
|
||||||
NSImage *icon = nil;
|
NSImage *icon = nil;
|
||||||
|
|
||||||
path = [object pathOfSelectedFile];
|
fileName = [object nameOfSelectedFile];
|
||||||
pathComponents = [path pathComponents];
|
if (fileName)
|
||||||
lastComponent = [path lastPathComponent];
|
{
|
||||||
fileExtension = [lastComponent pathExtension];
|
fileExtension = [fileName pathExtension];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
categoryName = [object nameOfSelectedCategory];
|
||||||
|
}
|
||||||
|
|
||||||
|
PCLogInfo(self,@"{setFileIcon} file %@ category %@",
|
||||||
|
fileName, categoryName);
|
||||||
|
|
||||||
// Should be provided by PC*Proj bundles
|
// Should be provided by PC*Proj bundles
|
||||||
if ([[object selectedFiles] count] > 1 && [pathComponents count] > 2)
|
if ([[object selectedFiles] count] > 1)
|
||||||
{
|
{
|
||||||
iconName = [[NSString alloc] initWithString:@"MultiFiles"];
|
iconName = [[NSString alloc] initWithString:@"MultiFiles"];
|
||||||
}
|
}
|
||||||
else if ([lastComponent isEqualToString: @"/"])
|
else if (!categoryName && !fileName) // Nothing selected
|
||||||
{
|
{
|
||||||
iconName = [[NSString alloc] initWithString:@"projectSuitcase"];
|
iconName = [[NSString alloc] initWithString:@"projectSuitcase"];
|
||||||
}
|
}
|
||||||
else if ([lastComponent isEqualToString: @"Classes"])
|
else if ([categoryName isEqualToString: @"Classes"])
|
||||||
{
|
{
|
||||||
iconName = [[NSString alloc] initWithString:@"classSuitcase"];
|
iconName = [[NSString alloc] initWithString:@"classSuitcase"];
|
||||||
}
|
}
|
||||||
else if ([lastComponent isEqualToString: @"Headers"])
|
else if ([categoryName isEqualToString: @"Headers"])
|
||||||
{
|
{
|
||||||
iconName = [[NSString alloc] initWithString:@"headerSuitcase"];
|
iconName = [[NSString alloc] initWithString:@"headerSuitcase"];
|
||||||
}
|
}
|
||||||
else if ([lastComponent isEqualToString: @"Other Sources"])
|
else if ([categoryName isEqualToString: @"Other Sources"])
|
||||||
{
|
{
|
||||||
iconName = [[NSString alloc] initWithString:@"genericSuitcase"];
|
iconName = [[NSString alloc] initWithString:@"genericSuitcase"];
|
||||||
}
|
}
|
||||||
else if ([lastComponent isEqualToString: @"Interfaces"])
|
else if ([categoryName isEqualToString: @"Interfaces"])
|
||||||
{
|
{
|
||||||
iconName = [[NSString alloc] initWithString:@"nibSuitcase"];
|
iconName = [[NSString alloc] initWithString:@"nibSuitcase"];
|
||||||
}
|
}
|
||||||
else if ([lastComponent isEqualToString: @"Images"])
|
else if ([categoryName isEqualToString: @"Images"])
|
||||||
{
|
{
|
||||||
iconName = [[NSString alloc] initWithString:@"iconSuitcase"];
|
iconName = [[NSString alloc] initWithString:@"iconSuitcase"];
|
||||||
}
|
}
|
||||||
else if ([lastComponent isEqualToString: @"Other Resources"])
|
else if ([categoryName isEqualToString: @"Other Resources"])
|
||||||
{
|
{
|
||||||
iconName = [[NSString alloc] initWithString:@"otherSuitcase"];
|
iconName = [[NSString alloc] initWithString:@"otherSuitcase"];
|
||||||
}
|
}
|
||||||
else if ([lastComponent isEqualToString: @"Subprojects"])
|
else if ([categoryName isEqualToString: @"Subprojects"])
|
||||||
{
|
{
|
||||||
iconName = [[NSString alloc] initWithString:@"subprojectSuitcase"];
|
iconName = [[NSString alloc] initWithString:@"subprojectSuitcase"];
|
||||||
}
|
}
|
||||||
else if ([lastComponent isEqualToString: @"Documentation"])
|
else if ([categoryName isEqualToString: @"Documentation"])
|
||||||
{
|
{
|
||||||
iconName = [[NSString alloc] initWithString:@"helpSuitcase"];
|
iconName = [[NSString alloc] initWithString:@"helpSuitcase"];
|
||||||
}
|
}
|
||||||
else if ([lastComponent isEqualToString: @"Supporting Files"])
|
else if ([categoryName isEqualToString: @"Supporting Files"])
|
||||||
{
|
{
|
||||||
iconName = [[NSString alloc] initWithString:@"genericSuitcase"];
|
iconName = [[NSString alloc] initWithString:@"genericSuitcase"];
|
||||||
}
|
}
|
||||||
else if ([lastComponent isEqualToString: @"Libraries"])
|
else if ([categoryName isEqualToString: @"Libraries"])
|
||||||
{
|
{
|
||||||
iconName = [[NSString alloc] initWithString:@"librarySuitcase"];
|
iconName = [[NSString alloc] initWithString:@"librarySuitcase"];
|
||||||
}
|
}
|
||||||
else if ([lastComponent isEqualToString: @"Non Project Files"])
|
else if ([categoryName isEqualToString: @"Non Project Files"])
|
||||||
{
|
{
|
||||||
iconName = [[NSString alloc] initWithString:@"projectSuitcase"];
|
iconName = [[NSString alloc] initWithString:@"projectSuitcase"];
|
||||||
}
|
}
|
||||||
|
@ -427,7 +435,7 @@
|
||||||
}
|
}
|
||||||
else if (fileExtension != nil && ![fileExtension isEqualToString:@""])
|
else if (fileExtension != nil && ![fileExtension isEqualToString:@""])
|
||||||
{
|
{
|
||||||
icon = [[NSWorkspace sharedWorkspace] iconForFile:lastComponent];
|
icon = [[NSWorkspace sharedWorkspace] iconForFile:fileName];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set icon to Project Window and Project Inspector
|
// Set icon to Project Window and Project Inspector
|
||||||
|
@ -437,15 +445,19 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set title
|
// Set title
|
||||||
if ([[object selectedFiles] count] > 1 && [pathComponents count] > 2)
|
if ([[object selectedFiles] count] > 1)
|
||||||
{
|
{
|
||||||
[fileIconTitle setStringValue:
|
[fileIconTitle setStringValue:
|
||||||
[NSString stringWithFormat:
|
[NSString stringWithFormat:
|
||||||
@"%i files", [[object selectedFiles] count]]];
|
@"%i files", [[object selectedFiles] count]]];
|
||||||
}
|
}
|
||||||
else
|
else if (fileName)
|
||||||
{
|
{
|
||||||
[fileIconTitle setStringValue:lastComponent];
|
[fileIconTitle setStringValue:fileName];
|
||||||
|
}
|
||||||
|
else if (categoryName)
|
||||||
|
{
|
||||||
|
[fileIconTitle setStringValue:categoryName];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Project Inspector
|
// Project Inspector
|
||||||
|
@ -531,7 +543,7 @@
|
||||||
|
|
||||||
if ([self hasLoadedFilesView])
|
if ([self hasLoadedFilesView])
|
||||||
{
|
{
|
||||||
if ([panel isVisible])
|
if (panel && [panel isVisible])
|
||||||
{
|
{
|
||||||
[panel close];
|
[panel close];
|
||||||
}
|
}
|
||||||
|
@ -542,7 +554,6 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// [[[project projectLoadedFiles] componentView] removeFromSuperview];
|
|
||||||
[componentView setBorderType:NSNoBorder];
|
[componentView setBorderType:NSNoBorder];
|
||||||
[panel orderFront:nil];
|
[panel orderFront:nil];
|
||||||
[v_split adjustSubviews];
|
[v_split adjustSubviews];
|
||||||
|
@ -602,7 +613,7 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (launchPanel)
|
if ([launchPanel isVisible])
|
||||||
{
|
{
|
||||||
[launchPanel close];
|
[launchPanel close];
|
||||||
}
|
}
|
||||||
|
@ -705,10 +716,10 @@
|
||||||
|
|
||||||
- (void)projectDictDidChange:(NSNotification *)aNotif
|
- (void)projectDictDidChange:(NSNotification *)aNotif
|
||||||
{
|
{
|
||||||
NSArray *sps = [project loadedSubprojects];
|
PCProject *changedProject = [aNotif object];
|
||||||
|
|
||||||
if ([aNotif object] != project
|
if (changedProject != project
|
||||||
&& ![sps containsObject:[aNotif object]])
|
&& [[project projectManager] activeProject] != changedProject)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -716,7 +727,7 @@
|
||||||
[self setTitle];
|
[self setTitle];
|
||||||
|
|
||||||
// TODO: if window isn't visible and "edited" attribute set, after ordering
|
// TODO: if window isn't visible and "edited" attribute set, after ordering
|
||||||
// out window doesn't show broken close button. Fix it in GNUstep.
|
// front window doesn't show broken close button. Fix it in GNUstep.
|
||||||
// Workaround is in windowDidBecomeKey.
|
// Workaround is in windowDidBecomeKey.
|
||||||
[projectWindow setDocumentEdited:YES];
|
[projectWindow setDocumentEdited:YES];
|
||||||
}
|
}
|
||||||
|
@ -868,10 +879,6 @@
|
||||||
{
|
{
|
||||||
firstResponder = aResponder;
|
firstResponder = aResponder;
|
||||||
[projectWindow makeFirstResponder:firstResponder];
|
[projectWindow makeFirstResponder:firstResponder];
|
||||||
if (![projectWindow isKeyWindow])
|
|
||||||
{
|
|
||||||
[self makeKeyWindow];
|
|
||||||
}
|
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -879,17 +886,25 @@
|
||||||
- (void)windowDidBecomeKey:(NSNotification *)aNotification
|
- (void)windowDidBecomeKey:(NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
[projectWindow makeMainWindow];
|
[projectWindow makeMainWindow];
|
||||||
[projectWindow makeFirstResponder:(NSResponder *)firstResponder];
|
// [projectWindow makeFirstResponder:(NSResponder *)firstResponder];
|
||||||
|
|
||||||
if ([project activeSubproject] != nil)
|
PCLogInfo(self, @"windowDidBecomeKey: activeSubproject %@",
|
||||||
|
[[project activeSubproject] projectName]);
|
||||||
|
|
||||||
|
if ([[project projectManager] rootActiveProject] != project)
|
||||||
{
|
{
|
||||||
[[project projectManager] setActiveProject:[project activeSubproject]];
|
if ([project activeSubproject] != nil)
|
||||||
}
|
{
|
||||||
else
|
[[project projectManager]
|
||||||
{
|
setActiveProject:[project activeSubproject]];
|
||||||
[[project projectManager] setActiveProject:project];
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[[project projectManager] setActiveProject:project];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Workaround
|
// Workaround
|
||||||
if ([projectWindow isDocumentEdited])
|
if ([projectWindow isDocumentEdited])
|
||||||
{
|
{
|
||||||
|
@ -900,7 +915,7 @@
|
||||||
|
|
||||||
- (void)windowDidResignKey:(NSNotification *)aNotification
|
- (void)windowDidResignKey:(NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
[projectWindow makeFirstResponder:nil];
|
// [projectWindow makeFirstResponder:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidBecomeMain:(NSNotification *)aNotification
|
- (void)windowDidBecomeMain:(NSNotification *)aNotification
|
||||||
|
@ -914,20 +929,6 @@
|
||||||
|
|
||||||
- (void)windowWillClose:(NSNotification *)aNotification
|
- (void)windowWillClose:(NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
/* [project close];
|
|
||||||
if ([aNotification object] == projectWindow)
|
|
||||||
{
|
|
||||||
if ([projectWindow isDocumentEdited])
|
|
||||||
{
|
|
||||||
if (NSRunAlertPanel(@"Close Project",
|
|
||||||
@"The project %@ has been edited!\nShould it be saved before closing?",
|
|
||||||
@"Yes",@"No",nil,[project projectName]))
|
|
||||||
{
|
|
||||||
[project save];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[project close];
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -393,7 +393,7 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification";
|
||||||
|
|
||||||
- (void)updateInspectorValues:(NSNotification *)aNotif
|
- (void)updateInspectorValues:(NSNotification *)aNotif
|
||||||
{
|
{
|
||||||
NSLog (@"PCAppProject: updateInspectorValues");
|
// NSLog (@"PCAppProject: updateInspectorValues");
|
||||||
|
|
||||||
// Project Attributes view
|
// Project Attributes view
|
||||||
[projectTypeField setStringValue:[projectDict objectForKey:PCProjectType]];
|
[projectTypeField setStringValue:[projectDict objectForKey:PCProjectType]];
|
||||||
|
|
|
@ -285,32 +285,36 @@
|
||||||
{
|
{
|
||||||
NSString *mainNibFile = [projectDict objectForKey:PCMainInterfaceFile];
|
NSString *mainNibFile = [projectDict objectForKey:PCMainInterfaceFile];
|
||||||
NSString *appIcon = [projectDict objectForKey:PCAppIcon];
|
NSString *appIcon = [projectDict objectForKey:PCAppIcon];
|
||||||
NSString *key = [self selectedRootCategoryKey];
|
NSString *categoryKey = nil;
|
||||||
NSString *ff = [fromFile copy];
|
NSString *ff = [fromFile copy];
|
||||||
NSString *tf = [toFile copy];
|
NSString *tf = [toFile copy];
|
||||||
BOOL success = NO;
|
BOOL success = NO;
|
||||||
|
|
||||||
|
categoryKey = [self
|
||||||
|
keyForCategory:[projectBrowser nameOfSelectedRootCategory]];
|
||||||
// Check for main NIB file
|
// Check for main NIB file
|
||||||
if ([key isEqualToString:PCInterfaces]
|
if ([categoryKey isEqualToString:PCInterfaces]
|
||||||
&& [fromFile isEqualToString:mainNibFile])
|
&& [fromFile isEqualToString:mainNibFile])
|
||||||
{
|
{
|
||||||
[self clearMainNib:self];
|
[self clearMainNib:self];
|
||||||
if ([super renameFile:ff toFile:tf] == YES)
|
if ([super renameFile:ff toFile:tf] == YES)
|
||||||
{
|
{
|
||||||
[self setMainNibWithFileAtPath:
|
[self setMainNibWithFileAtPath:
|
||||||
[[self dirForCategoryKey:key] stringByAppendingPathComponent:tf]];
|
[[self dirForCategoryKey:categoryKey]
|
||||||
|
stringByAppendingPathComponent:tf]];
|
||||||
success = YES;
|
success = YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check for application icon files
|
// Check for application icon files
|
||||||
else if ([key isEqualToString:PCImages]
|
else if ([categoryKey isEqualToString:PCImages]
|
||||||
&& [fromFile isEqualToString:appIcon])
|
&& [fromFile isEqualToString:appIcon])
|
||||||
{
|
{
|
||||||
[self clearAppIcon:self];
|
[self clearAppIcon:self];
|
||||||
if ([super renameFile:ff toFile:tf] == YES)
|
if ([super renameFile:ff toFile:tf] == YES)
|
||||||
{
|
{
|
||||||
[self setAppIconWithImageAtPath:
|
[self setAppIconWithImageAtPath:
|
||||||
[[self dirForCategoryKey:key] stringByAppendingPathComponent:tf]];
|
[[self dirForCategoryKey:categoryKey]
|
||||||
|
stringByAppendingPathComponent:tf]];
|
||||||
success = YES;
|
success = YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -319,9 +323,6 @@
|
||||||
success = YES;
|
success = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
[projectBrowser setPathForFile:toFile
|
|
||||||
category:[self categoryForKey:key]];
|
|
||||||
|
|
||||||
[ff release];
|
[ff release];
|
||||||
[tf release];
|
[tf release];
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,7 @@
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
|
NSLog(@"PCBundleProject: dealloc");
|
||||||
[rootCategories release];
|
[rootCategories release];
|
||||||
[rootKeys release];
|
[rootKeys release];
|
||||||
[rootEntries release];
|
[rootEntries release];
|
||||||
|
|
|
@ -99,7 +99,7 @@
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
NSLog (@"PCAppProject: dealloc");
|
NSLog (@"PCRenaissanceProject: dealloc");
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
|
|
||||||
|
@ -139,8 +139,6 @@
|
||||||
|
|
||||||
- (NSArray *)fileTypesForCategoryKey:(NSString *)key
|
- (NSArray *)fileTypesForCategoryKey:(NSString *)key
|
||||||
{
|
{
|
||||||
// NSLog(@"fileTypesForCategoryKey: %@", key);
|
|
||||||
|
|
||||||
if ([key isEqualToString:PCClasses])
|
if ([key isEqualToString:PCClasses])
|
||||||
{
|
{
|
||||||
return [NSArray arrayWithObjects:@"m",nil];
|
return [NSArray arrayWithObjects:@"m",nil];
|
||||||
|
@ -298,32 +296,37 @@
|
||||||
{
|
{
|
||||||
NSString *mainNibFile = [projectDict objectForKey:PCMainInterfaceFile];
|
NSString *mainNibFile = [projectDict objectForKey:PCMainInterfaceFile];
|
||||||
NSString *appIcon = [projectDict objectForKey:PCAppIcon];
|
NSString *appIcon = [projectDict objectForKey:PCAppIcon];
|
||||||
NSString *key = [self selectedRootCategoryKey];
|
NSString *categoryKey = nil;
|
||||||
NSString *ff = [fromFile copy];
|
NSString *ff = [fromFile copy];
|
||||||
NSString *tf = [toFile copy];
|
NSString *tf = [toFile copy];
|
||||||
BOOL success = NO;
|
BOOL success = NO;
|
||||||
|
|
||||||
|
categoryKey = [self
|
||||||
|
keyForCategory:[projectBrowser nameOfSelectedRootCategory]];
|
||||||
|
|
||||||
// Check for main NIB file
|
// Check for main NIB file
|
||||||
if ([key isEqualToString:PCInterfaces]
|
if ([categoryKey isEqualToString:PCInterfaces]
|
||||||
&& [fromFile isEqualToString:mainNibFile])
|
&& [fromFile isEqualToString:mainNibFile])
|
||||||
{
|
{
|
||||||
[self clearMainNib:self];
|
[self clearMainNib:self];
|
||||||
if ([super renameFile:ff toFile:tf] == YES)
|
if ([super renameFile:ff toFile:tf] == YES)
|
||||||
{
|
{
|
||||||
[self setMainNibWithFileAtPath:
|
[self setMainNibWithFileAtPath:
|
||||||
[[self dirForCategoryKey:key] stringByAppendingPathComponent:tf]];
|
[[self dirForCategoryKey:categoryKey]
|
||||||
|
stringByAppendingPathComponent:tf]];
|
||||||
success = YES;
|
success = YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check for application icon files
|
// Check for application icon files
|
||||||
else if ([key isEqualToString:PCImages]
|
else if ([categoryKey isEqualToString:PCImages]
|
||||||
&& [fromFile isEqualToString:appIcon])
|
&& [fromFile isEqualToString:appIcon])
|
||||||
{
|
{
|
||||||
[self clearAppIcon:self];
|
[self clearAppIcon:self];
|
||||||
if ([super renameFile:ff toFile:tf] == YES)
|
if ([super renameFile:ff toFile:tf] == YES)
|
||||||
{
|
{
|
||||||
[self setAppIconWithImageAtPath:
|
[self setAppIconWithImageAtPath:
|
||||||
[[self dirForCategoryKey:key] stringByAppendingPathComponent:tf]];
|
[[self dirForCategoryKey:categoryKey]
|
||||||
|
stringByAppendingPathComponent:tf]];
|
||||||
success = YES;
|
success = YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,9 +335,6 @@
|
||||||
success = YES;
|
success = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
[projectBrowser setPathForFile:toFile
|
|
||||||
category:[self categoryForKey:key]];
|
|
||||||
|
|
||||||
[ff release];
|
[ff release];
|
||||||
[tf release];
|
[tf release];
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,6 @@
|
||||||
// Subproject
|
// Subproject
|
||||||
- (void)subprojectNew:(id)sender;
|
- (void)subprojectNew:(id)sender;
|
||||||
- (void)subprojectAdd:(id)sender;
|
- (void)subprojectAdd:(id)sender;
|
||||||
- (void)subprojectRemove:(id)sender;
|
|
||||||
|
|
||||||
// File
|
// File
|
||||||
- (void)fileNew:(id)sender;
|
- (void)fileNew:(id)sender;
|
||||||
|
|
|
@ -140,16 +140,7 @@
|
||||||
|
|
||||||
- (void)subprojectAdd:(id)sender
|
- (void)subprojectAdd:(id)sender
|
||||||
{
|
{
|
||||||
NSString *proj = nil;
|
[projectManager addSubproject];
|
||||||
|
|
||||||
// Show open panel
|
|
||||||
|
|
||||||
[projectManager addSubprojectAt:proj];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)subprojectRemove:(id)sender
|
|
||||||
{
|
|
||||||
[projectManager removeSubproject];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// File
|
// File
|
||||||
|
@ -371,8 +362,10 @@
|
||||||
|
|
||||||
- (BOOL)validateMenuItem:(id <NSMenuItem>)menuItem
|
- (BOOL)validateMenuItem:(id <NSMenuItem>)menuItem
|
||||||
{
|
{
|
||||||
NSString *menuTitle = [[menuItem menu] title];
|
NSString *menuTitle = [[menuItem menu] title];
|
||||||
PCProject *aProject = [projectManager activeProject];
|
PCProject *aProject = [projectManager activeProject];
|
||||||
|
PCProjectEditor *projectEditor = [aProject projectEditor];
|
||||||
|
PCProjectBrowser *projectBrowser = [aProject projectBrowser];
|
||||||
|
|
||||||
if ([[projectManager loadedProjects] count] == 0)
|
if ([[projectManager loadedProjects] count] == 0)
|
||||||
{
|
{
|
||||||
|
@ -456,10 +449,26 @@
|
||||||
|
|
||||||
// Project related menu items
|
// Project related menu items
|
||||||
if ([menuTitle isEqualToString: @"Project"]
|
if ([menuTitle isEqualToString: @"Project"]
|
||||||
&& [aProject selectedRootCategory] == nil)
|
&& [projectBrowser nameOfSelectedFile] == nil
|
||||||
|
&& [projectBrowser selectedFiles] == nil)
|
||||||
|
{
|
||||||
|
if ([[menuItem title] isEqualToString:@"Remove Files..."]) return NO;
|
||||||
|
}
|
||||||
|
if ([menuTitle isEqualToString: @"Project"]
|
||||||
|
&& [[projectEditor allEditors] count] == 0)
|
||||||
|
{
|
||||||
|
if ([[menuItem title] isEqualToString:@"Save Files..."]) return NO;
|
||||||
|
}
|
||||||
|
if ([menuTitle isEqualToString: @"Project"]
|
||||||
|
&& [projectBrowser nameOfSelectedCategory] == nil)
|
||||||
{
|
{
|
||||||
if ([[menuItem title] isEqualToString:@"Add Files..."]) return NO;
|
if ([[menuItem title] isEqualToString:@"Add Files..."]) return NO;
|
||||||
if ([[menuItem title] isEqualToString:@"Remove Files..."]) return NO;
|
if ([[menuItem title] isEqualToString:@"Add Subproject..."]) return NO;
|
||||||
|
}
|
||||||
|
if ([menuTitle isEqualToString: @"Project"]
|
||||||
|
&& ![[projectBrowser nameOfSelectedRootCategory] isEqualToString:@"Subprojects"])
|
||||||
|
{
|
||||||
|
if ([[menuItem title] isEqualToString:@"Add Subproject..."]) return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// File related menu items
|
// File related menu items
|
||||||
|
@ -474,7 +483,7 @@
|
||||||
if ([[menuItem title] isEqualToString:@"Close"]) return NO;
|
if ([[menuItem title] isEqualToString:@"Close"]) return NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ([[aProject projectBrowser] nameOfSelectedFile] == nil)
|
if ([projectBrowser nameOfSelectedFile] == nil)
|
||||||
{
|
{
|
||||||
if ([[menuItem title] isEqualToString:@"Rename"]) return NO;
|
if ([[menuItem title] isEqualToString:@"Rename"]) return NO;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue