Cleaned up the code which is called upon seleting a file in the project

browser. Now libraries etc. do not show up in the internal editor anymore.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@12613 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Philippe C.D. Robert 2002-02-21 10:05:42 +00:00
parent 9f0c48d05b
commit 4ee31e2a7c
4 changed files with 50 additions and 31 deletions

View file

@ -42,6 +42,8 @@
- (void)click:(id)sender;
- (void)doubleClick:(id)sender;
- (BOOL)isEditableCategory:(NSString *)category;
- (void)projectDictDidChange:(NSNotification *)aNotif;
- (NSString *)nameOfSelectedFile;

View file

@ -25,8 +25,6 @@
*/
#import "PCBrowserController.h"
#import "PCEditorController.h"
#import "PCEditor.h"
#import "PCProject.h"
#import "PCFileManager.h"
@ -43,42 +41,31 @@
{
if ([[sender selectedCell] isLeaf])
{
NSString *ltitle = [[sender selectedCell] stringValue];
NSString *ctitle = [[sender selectedCellInColumn:0] stringValue];
NSString *ctitlef = [[project projectPath] stringByAppendingPathComponent:ltitle];
NSString *ltitle = [[sender selectedCell] stringValue];
NSString *category = [[sender selectedCellInColumn:0] stringValue];
[project browserDidSelectFileNamed:ltitle];
if ([self isEditableCategory:category])
{
[project browserDidClickFile:ltitle category:category];
}
}
}
- (void)doubleClick:(id)sender
{
if ([sender selectedColumn] != 0)
if ([[sender selectedCell] isLeaf])
{
NSString *category = [[[browser path] componentsSeparatedByString:@"/"] objectAtIndex:1];
NSString *k = [[project rootCategories] objectForKey:category];
NSString *category = [[sender selectedCellInColumn:0] stringValue];
NSString *fn = [self nameOfSelectedFile];
NSString *f = [[project projectPath] stringByAppendingPathComponent:fn];
if ([k isEqualToString:PCClasses] ||
[k isEqualToString:PCHeaders] ||
[k isEqualToString:PCOtherSources])
if ([self isEditableCategory:category])
{
NSString *projectPath = [project projectPath];
NSString *fn = [self nameOfSelectedFile];
NSString *file = [projectPath stringByAppendingPathComponent:fn];
[[[project editorController] editorForFile:file] show];
[project browserDidDblClickFile:f category:category];
}
else
else if([[NSWorkspace sharedWorkspace] openFile:f] == NO)
{
NSString *fi;
NSString *sf = [self nameOfSelectedFile];
fi = [[project projectPath] stringByAppendingPathComponent:sf];
if([[NSWorkspace sharedWorkspace] openFile:fi] == NO)
{
NSRunAlertPanel(@"Attention!",@"Could not open %@.",@"OK",nil,nil,fi);
}
NSRunAlertPanel(@"Attention!",@"Could not open %@.",@"OK",nil,nil,f);
}
}
else
@ -87,6 +74,23 @@
}
}
- (BOOL)isEditableCategory:(NSString *)category
{
NSString *k = [[project rootCategories] objectForKey:category];
if ([k isEqualToString:PCClasses] ||
[k isEqualToString:PCHeaders] ||
[k isEqualToString:PCOtherResources] ||
[k isEqualToString:PCSupportingFiles] ||
[k isEqualToString:PCDocuFiles] ||
[k isEqualToString:PCOtherSources])
{
return YES;
}
return NO;
}
- (void)projectDictDidChange:(NSNotification *)aNotif
{
if (browser) {
@ -133,8 +137,8 @@
- (void)setProject:(PCProject *)aProj
{
[project autorelease];
project = [aProj retain];
AUTORELEASE(project);
project = RETAIN(aProj);
}
@end

View file

@ -212,7 +212,8 @@ static NSString * const PCBuildTool = @"BUILDTOOL";
// ==== File Handling
//=============================================================================
- (void)browserDidSelectFileNamed:(NSString *)fileName;
- (void)browserDidClickFile:(NSString *)fileName category:(NSString*)c;
- (void)browserDidDblClickFile:(NSString *)fileName category:(NSString*)c;
- (BOOL)doesAcceptFile:(NSString *)file forKey:(NSString *)key;
// Returns YES if type is a valid key and file is not contained in the project already

View file

@ -637,7 +637,7 @@
// ==== File Handling
//=============================================================================
- (void)browserDidSelectFileNamed:(NSString *)fileName
- (void)browserDidClickFile:(NSString *)fileName category:(NSString*)c
{
NSString *p = [[self projectPath] stringByAppendingPathComponent:fileName];
PCEditor *e;
@ -660,6 +660,18 @@
[projectWindow makeFirstResponder:[projectEditor editorView]];
}
- (void)browserDidDblClickFile:(NSString *)fileName category:(NSString*)c
{
PCEditor *e;
e = [editorController editorForFile:fileName];
if( e )
{
[e show];
}
}
- (BOOL)doesAcceptFile:(NSString *)file forKey:(NSString *)type
{
if ([[projectDict allKeys] containsObject:type]) {