2010-07-31 Sergii Stoian <stoyan255@ukr.net>

* Framework/PCProject.m:
        (-assignProjectDict:): Fix setting projectPath to project
        dir (not to *.pcproj dir).
        * Framework/PCFilemanager.m:
        (-filesOfTypes:operation:multiple:title:accView:): Set allowed
        file types to panel of types is not nil.
        (-panel:isValidFilename): Use set allowed file types to panel.

2010-07-30 Sergii Stoian <stoyan255@ukr.net>
        * Framework/PCProject.m:
        (-subprojectWithName:): Pass to openProjectAt: subproject dir.
        openProjectat: can now handle this situation.
        * Framework/PCProjectManager.m:
        (-openProjectAt:): Implement handling of 'aPath' argument as
        project file and as project dir. Select *.pcproj if exists then
        try to load PC.project.
        (-openProject): Implement intelligent selection of project file
        when selected *.pcproj, PC.project or project dir.
        * Framework/PCFilemanager.m:
        (-filesOfTypes:operation:multiple:title:accView:): Remove code
        specific for opening projects (moved to PCProjectManager's
        openProject).
        (-panel:isValidFilename): Fix handling project file detection.
        (-filesWithExtension:atPath:includeDirs:): New method. Returns
        list of files with specified extension. Also returns dirs if
        'includeDirs' set to YES.

2010-07-28 Sergii Stoian <stoyan255@ukr.net>
        * Framework/PCProject.m:
        (close:): Fix closing of subprojects. Remove subproject from
        Projectmanager's list of loaded projects.
        * Framework/PCLogController.m:
        (-init): Change font size to systemFontSize.

2010-07-24 Sergii Stoian <stoyan255@ukr.net>
        * Headers/ProjectCenter/PCProjectBuilder.m:
        * Framework/PCProjectBuilder.m:
        (cleanupAfterMake:): Added new argument (NSString) to method
        containing current status text. Before status text in project window
        always stated "...terminated".


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@31093 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Sergii Stoian 2010-08-07 21:56:04 +00:00
parent 039b7f2d99
commit 18efb7552d
10 changed files with 222 additions and 88 deletions

View file

@ -1,3 +1,45 @@
2010-07-31 Sergii Stoian <stoyan255@ukr.net>
* Framework/PCProject.m:
(-assignProjectDict:): Fix setting projectPath to project
dir (not to *.pcproj dir).
* Framework/PCFilemanager.m:
(-filesOfTypes:operation:multiple:title:accView:): Set allowed
file types to panel of types is not nil.
(-panel:isValidFilename): Use set allowed file types to panel.
2010-07-30 Sergii Stoian <stoyan255@ukr.net>
* Framework/PCProject.m:
(-subprojectWithName:): Pass to openProjectAt: subproject dir.
openProjectat: can now handle this situation.
* Framework/PCProjectManager.m:
(-openProjectAt:): Implement handling of 'aPath' argument as
project file and as project dir. Select *.pcproj if exists then
try to load PC.project.
(-openProject): Implement intelligent selection of project file
when selected *.pcproj, PC.project or project dir.
* Framework/PCFilemanager.m:
(-filesOfTypes:operation:multiple:title:accView:): Remove code
specific for opening projects (moved to PCProjectManager's
openProject).
(-panel:isValidFilename): Fix handling project file detection.
(-filesWithExtension:atPath:includeDirs:): New method. Returns
list of files with specified extension. Also returns dirs if
'includeDirs' set to YES.
2010-07-28 Sergii Stoian <stoyan255@ukr.net>
* Framework/PCProject.m:
(close:): Fix closing of subprojects. Remove subproject from
Projectmanager's list of loaded projects.
* Framework/PCLogController.m:
(-init): Change font size to systemFontSize.
2010-07-24 Sergii Stoian <stoyan255@ukr.net>
* Headers/ProjectCenter/PCProjectBuilder.m:
* Framework/PCProjectBuilder.m:
(cleanupAfterMake:): Added new argument (NSString) to method
containing current status text. Before status text in project window
always stated "...terminated".
2010-07-13 Riccardo Mottola <rmottola@users.sf.net>
* Framework/PCProjectManager.m

View file

@ -442,30 +442,21 @@ static PCFileManager *_mgr = nil;
{
id panel;
NSMutableArray *fileList = [[NSMutableArray alloc] init];
NSString *file;
NSFileManager *fm = [NSFileManager defaultManager];
BOOL isDir;
int result;
int result = -10;
panel = [self _panelForOperation:op title:title accView:accessoryView];
if (types != nil)
{
[panel setAllowedFileTypes:types];
}
if ((op == PCOpenFileOperation) ||
(op == PCOpenProjectOperation) ||
(op == PCOpenDirectoryOperation))
{
[panel setAllowsMultipleSelection:yn];
if ((result = [panel runModalForTypes:types]) == NSOKButton)
{
[fileList addObjectsFromArray:[panel filenames]];
file = [fileList objectAtIndex:0];
if (op == PCOpenProjectOperation &&
[fm fileExistsAtPath:file isDirectory:&isDir] && isDir)
{
file = [file stringByAppendingPathComponent:@"PC.project"];
[fileList insertObject:file atIndex:0];
}
}
}
else if (op == PCSaveFileOperation)
@ -570,17 +561,26 @@ static PCFileManager *_mgr = nil;
{
NSFileManager *fm = [NSFileManager defaultManager];
BOOL isDir;
NSString *file;
NSEnumerator *e = nil;
NSArray *tempList = nil;
NSString *tempExtension = nil;
if (operation == PCOpenProjectOperation)
{
if ([fm fileExistsAtPath:filename isDirectory:&isDir] && isDir)
{
file = [filename stringByAppendingPathComponent:@"PC.project"];
if ([fm fileExistsAtPath:file])
e = [[sender allowedFileTypes] objectEnumerator];
while ((tempExtension = [e nextObject]) != nil)
{
return YES;
tempList = [self filesWithExtension:tempExtension
atPath:filename
includeDirs:YES];
if ([tempList count] > 0)
{
return YES;
}
}
return NO;
}
}
@ -590,7 +590,7 @@ static PCFileManager *_mgr = nil;
@end
@implementation PCFileManager (FileType)
@implementation PCFileManager (Misc)
/**
* Returns YES if the file identified by `filename' is a text file,
@ -634,4 +634,31 @@ static PCFileManager *_mgr = nil;
return (((double) printable / n) > 0.9);
}
- (NSArray *)filesWithExtension:(NSString *)extension
atPath:(NSString *)dirPath
includeDirs:(BOOL)incDirs
{
NSFileManager *fm = [NSFileManager defaultManager];
NSMutableArray *filesList = [[NSMutableArray alloc] init];
NSEnumerator *e = nil;
NSString *temp = nil;
BOOL isDir;
e = [[fm directoryContentsAtPath:dirPath] objectEnumerator];
while ((temp = [e nextObject]) != nil)
{
if ([fm fileExistsAtPath:temp isDirectory:&isDir] && isDir && !incDirs)
{
continue;
}
if ([[temp pathExtension] isEqual:extension])
{
[filesList addObject:[dirPath stringByAppendingPathComponent:temp]];
}
}
return [filesList autorelease];
}
@end

View file

@ -114,7 +114,7 @@ static PCLogController *_logCtrllr = nil;
[panel center];
}
font = [NSFont userFixedPitchFontOfSize:[NSFont smallSystemFontSize]];
font = [NSFont userFixedPitchFontOfSize:[NSFont systemFontSize]];
textAttributes =
[NSMutableDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
[textAttributes retain];

View file

@ -175,9 +175,11 @@ NSString
// --- Dictionary
- (BOOL)assignProjectDict:(NSDictionary *)pDict atPath:(NSString *)pPath
{
NSString *tempPath = nil;
NSAssert(pDict,@"No valid project dictionary!");
PCLogStatus(self, @"assignProjectDict");
PCLogStatus(self, @"assignProjectDict at %@", pPath);
if (projectDict)
{
@ -189,7 +191,12 @@ NSString
if ([[pPath lastPathComponent] isEqualToString:@"PC.project"] ||
[[[pPath lastPathComponent] pathExtension] isEqualToString:@"pcproj"])
{
[self setProjectPath:[pPath stringByDeletingLastPathComponent]];
tempPath = [pPath stringByDeletingLastPathComponent];
if ([[tempPath pathExtension] isEqualToString:@"pcproj"])
{
tempPath = [tempPath stringByDeletingLastPathComponent];
}
[self setProjectPath:tempPath];
}
else
{
@ -593,6 +600,7 @@ NSString
if (isSubproject == YES)
{
[projectManager closeProject:self];
return YES;
}
@ -1519,7 +1527,7 @@ NSString
int i;
PCProject *sp = nil;
NSString *spName = nil;
NSString *spFile = nil;
NSString *spPath = nil;
// Subproject in project but not loaded
if ([[projectDict objectForKey:PCSubprojects] containsObject:name])
@ -1541,12 +1549,10 @@ NSString
// Subproject not found in array, load it
if (sp == nil)
{
NSString *pname = [NSString stringWithFormat: @"%@.pcproj",name];
spFile = [projectPath stringByAppendingPathComponent:name];
spFile = [spFile stringByAppendingPathExtension:@"subproj"];
spFile = [spFile stringByAppendingPathComponent: pname];
spPath = [projectPath stringByAppendingPathComponent:name];
spPath = [spPath stringByAppendingPathExtension:@"subproj"];
sp = [projectManager openProjectAt:spFile makeActive:NO];
sp = [projectManager openProjectAt:spPath makeActive:NO];
if (sp)
{
[sp setIsSubproject:YES];

View file

@ -382,14 +382,17 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification";
filePath = [self pathToSelectedFile];
fileName = [self nameOfSelectedFile];
NSLog(@"category: %@ forProject: %@",
category, [activeProject projectName]);
NSLog(@"[click]category: %@ forProject: %@ fileName: %@",
category, [activeProject projectName], fileName);
if (filePath &&
[filePath isEqualToString:browserPath] &&
![fileName isEqualToString:[activeProject projectName]])
![fileName isEqualToString:[activeProject projectName]] &&
![category isEqualToString:@"Subprojects"] &&
![category isEqualToString:@"Libraries"]
)
{
// NSLog(@"[click] category: %@ filePath: %@", category, filePath);
NSLog(@"[click] category: %@ filePath: %@", category, filePath);
[[activeProject projectEditor] openEditorForCategoryPath:browserPath
windowed:NO];
}

View file

@ -447,14 +447,14 @@
[buildOptions show:[[componentView window] frame]];
}
- (void)cleanupAfterMake
- (void)cleanupAfterMake:(NSString *)statusString
{
NSString *statusString;
// NSString *statusString;
if (_isBuilding || _isCleaning)
{
statusString =[NSString stringWithFormat:
@"%@ - %@ terminated", [project projectName], buildStatusTarget];
// statusString =[NSString stringWithFormat:
// @"%@ - %@ terminated", [project projectName], buildStatusTarget];
[statusField setStringValue:statusString];
[[project projectWindow] updateStatusLineWithText:statusString];
}
@ -564,7 +564,8 @@
// Checking build conditions
if ([self prebuildCheck] == NO)
{
[self cleanupAfterMake];
[self cleanupAfterMake:[NSString stringWithFormat:
@"%@ - %@ terminated", [project projectName], buildStatusTarget]];
return;
}
@ -715,7 +716,7 @@
postProcess = NULL;
}*/
[self cleanupAfterMake];
[self cleanupAfterMake:statusString];
}
// --- BuilderOptions delegate

View file

@ -544,56 +544,91 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
return project;
}
// aPath is path to a project file PC.project or project bundle *.pcproj.
// Also it can be project directory where one of the above resides.
- (PCProject *)openProjectAt:(NSString *)aPath makeActive: (BOOL)flag
{
NSString *projectPath = nil;
NSString *projectFileType = nil;
PCProject *project = nil;
NSDictionary *wap = nil;
if ((project = [loadedProjects objectForKey: [aPath stringByDeletingLastPathComponent]]) == nil)
// Check project path for invalid characters
if ([aPath rangeOfString: @" "].location != NSNotFound ||
[aPath rangeOfString: @"\t"].location != NSNotFound ||
[aPath rangeOfString: @"\r"].location != NSNotFound ||
[aPath rangeOfString: @"\n"].location != NSNotFound)
{
if (NSRunAlertPanel
(@"Open Project",
@"Project path contains whitespaces.\n"
@"GNUstep's build environment currently "
@"can't handle that reliably.\n"
@"Do you want to open a project anyway?\n",
@"Open", @"Don't open", nil) != NSAlertDefaultReturn)
{
return nil;
}
}
projectFileType = [[aPath lastPathComponent] pathExtension];
if ([projectFileType isEqualToString:@"pcproj"] ||
[projectFileType isEqualToString:@"project"])
{
projectPath = [aPath stringByDeletingLastPathComponent];
}
else
{
projectPath = aPath;
}
if ((project = [loadedProjects objectForKey:projectPath])== nil)
{
NSMutableDictionary *projectFile = nil;
NSString *projectTypeName = nil;
NSString *projectClassName = nil;
BOOL isDir = NO;
BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:aPath
isDirectory: &isDir];
NSMutableDictionary *projectFile = nil;
NSString *projectTypeName = nil;
NSString *projectClassName = nil;
BOOL isDir = NO;
BOOL exists = NO;
NSArray *tempList;
exists = [[NSFileManager defaultManager] fileExistsAtPath:aPath
isDirectory:&isDir];
if (!exists)
{
return nil;
}
if ([aPath rangeOfString: @" "].location != NSNotFound ||
[aPath rangeOfString: @"\t"].location != NSNotFound ||
[aPath rangeOfString: @"\r"].location != NSNotFound ||
[aPath rangeOfString: @"\n"].location != NSNotFound)
if (isDir)
{
if (NSRunAlertPanel
(@"Open Project",
@"Are you sure you want to open a project with whitespace in it's path?\n"
@"GNUstep's build environment currently can't handle that reliably.",
@"OK", @"Cancel", nil) != NSAlertDefaultReturn)
if ([projectFileType isEqualToString:@"pcproj"] == NO)
{
return nil;
tempList = [fileManager filesWithExtension:@"pcproj"
atPath:aPath
includeDirs:YES];
if ([tempList count] > 0)
{
aPath = [tempList objectAtIndex:0];
}
}
aPath = [aPath stringByAppendingPathComponent:@"PC.project"];
projectFile = [NSMutableDictionary dictionaryWithContentsOfFile:aPath];
}
else if ([projectFileType isEqualToString:@"project"])
{
projectFile = [NSMutableDictionary dictionaryWithContentsOfFile:aPath];
}
else
{ //TODO: Remove support of 0.3.x projects
projectFile = [NSMutableDictionary dictionaryWithContentsOfFile:aPath];
if (projectFile != nil)
{
// For compatibility with 0.3.x projects
project = [self convertLegacyProject:projectFile atPath:aPath];
}
}
if (!isDir)
{
projectFile = [NSMutableDictionary dictionaryWithContentsOfFile: aPath];
if(projectFile == nil)
return nil;
// For compatibility with 0.3.x projects
project = [self convertLegacyProject: projectFile atPath: aPath];
}
else
{
projectFile = [NSMutableDictionary dictionaryWithContentsOfFile: [aPath stringByAppendingPathComponent: @"PC.project"]];
}
if(projectFile == nil)
if (projectFile == nil)
return nil;
if (project)
{// Project was converted and created PC*Project with alloc&init
@ -615,8 +650,8 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
}
project = [bundleManager objectForClassName:projectClassName
bundleType:@"project"
protocol:@protocol(ProjectType)];
bundleType:@"project"
protocol:@protocol(ProjectType)];
if (!project || ![project openWithWrapperAt:aPath])
{
@ -638,7 +673,7 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
return nil;
}
[loadedProjects setObject:project forKey: [project projectPath]];
[loadedProjects setObject:project forKey:[project projectPath]];
if (flag)
{
[project setProjectManager:self];
@ -668,11 +703,14 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
- (void)openProject
{
NSArray *files = nil;
NSString *filePath = nil, *temp = nil;
NSArray *fileTypes = [NSArray arrayWithObjects:@"pcproj",@"project",nil];
NSEnumerator *en = nil;
NSArray *fileTypes = nil;
NSArray *files = nil;
NSString *filePath = nil;
NSFileManager *fm = [NSFileManager defaultManager];
BOOL isDir;
NSArray *tempList = nil;
fileTypes = [NSArray arrayWithObjects:@"pcproj",@"project",nil];
files = [fileManager filesOfTypes:fileTypes
operation:PCOpenProjectOperation
multiple:NO
@ -680,18 +718,28 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
accView:nil];
filePath = [files objectAtIndex:0];
en = [files objectEnumerator];
while((temp = [en nextObject]) != nil)
[fm fileExistsAtPath:filePath isDirectory:&isDir];
if (isDir)
{
if([[temp pathExtension] isEqual: @"pcproj"])
if (![[filePath pathExtension] isEqualToString:@"pcproj"])
{
filePath = temp;
tempList = [fileManager filesWithExtension:@"pcproj"
atPath:filePath
includeDirs:YES];
if ([tempList count] > 0)
{
filePath = [tempList objectAtIndex:0];
}
}
filePath = [filePath stringByAppendingPathComponent:@"PC.project"];
}
NSLog(@"PCPM: openProject: %@", filePath);
if (filePath != nil)
{
[self openProjectAt:filePath makeActive: YES];
[self openProjectAt:filePath makeActive:YES];
}
}

View file

@ -30,7 +30,7 @@
ADDITIONAL_CPPFLAGS +=
# Additional flags to pass to the Objective-C compiler
ADDITIONAL_OBJCFLAGS +=
ADDITIONAL_OBJCFLAGS += -DDEVELOPMENT
# Additional flags to pass to the C compiler
ADDITIONAL_CFLAGS +=

View file

@ -125,9 +125,16 @@ enum {
@end
@interface PCFileManager (FileType)
@interface PCFileManager (Misc)
- (BOOL)isTextFile:(NSString *)filename;
// Return list of files and directories absolute paths that has
// specified 'extension' at directory 'dirPath'. If 'incDirs'
// has value YES also include directories in this list.
- (NSArray *)filesWithExtension:(NSString *)extension
atPath:(NSString *)dirPath
includeDirs:(BOOL)incDirs;
@end
#endif

View file

@ -124,7 +124,7 @@ typedef enum _ErrorLevel {
- (void)startClean:(id)sender;
- (BOOL)stopMake:(id)sender;
- (void)showOptionsPanel:(id)sender;
- (void)cleanupAfterMake;
- (void)cleanupAfterMake:(NSString *)statusString;
- (BOOL)prebuildCheck;
- (void)build:(id)sender;