PCAddFilesPanel added. Bugfixes in file adding code.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@20514 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Sergii Stoian 2005-01-03 00:20:54 +00:00
parent bb13a30ed7
commit 9cab0f9822
13 changed files with 155 additions and 142 deletions

View file

@ -1,3 +1,22 @@
2005-01-03 Serg Stoyan <stoyan255@ukr.net>
* Library/PCAddFilesPanel.[hm]: New implementation. Derived from
NSOpenPanel.
* Library/PCFileManager.m: Use PCAddFilesPanel instead of NSOpenPanel.
* Library/PCProject.m:
(projectFileFromFile:forKey:): Rewritten to correctly support
subprojects' files and libraries.
(addFiles:forKey:notify:): Add path to PCSearchLibs when adding
libraries.
* Library/PCProjectInspector.m: Observe project dictionary changes and
reread it.
* Library/PCProjectBrowser.m:
(doubleClick:): Don't try to open libraries.
2004-12-24 Serg Stoyan <stoyan255@ukr.net>
* "Build Tool" setting from Project Inspector was moved to PC

View file

@ -27,6 +27,7 @@ ProjectCenter_LIBRARIES_DEPEND_UPON += -lgnustep-gui
ProjectCenter_HEADER_FILES = \
PCBundleLoader.h \
PCFileManager.h \
PCAddFilesPanel.h \
PCFileCreator.h \
PCServer.h \
PCMakefileFactory.h \
@ -65,6 +66,7 @@ ProjectCenter_HEADER_FILES = \
ProjectCenter_OBJC_FILES = \
PCBundleLoader.m \
PCFileManager.m \
PCAddFilesPanel.m \
PCFileCreator.m \
PCServer.m \
PCMakefileFactory.m \

View file

@ -41,7 +41,7 @@
ADDITIONAL_CPPFLAGS +=
# Additional flags to pass to the Objective-C compiler
ADDITIONAL_OBJCFLAGS += -Wall -Werror
ADDITIONAL_OBJCFLAGS += -Wall
# Additional flags to pass to the C compiler
ADDITIONAL_CFLAGS +=

View file

@ -31,6 +31,7 @@
@class PCProject;
@class PCProjectManager;
@class PCAddFilesPanel;
@interface PCFileManager : NSObject
{
@ -48,9 +49,7 @@
IBOutlet NSButton *nfCancleButton;
IBOutlet NSButton *nfCreateButton;
NSOpenPanel *addFilesPanel;
NSBox *fileTypeAccessaryView;
NSPopUpButton *fileTypePopup;
PCAddFilesPanel *addFilesPanel;
}
//==============================================================================
@ -97,9 +96,7 @@
- (void)createFile:(id)sender;
- (void)newFilePopupChanged:(id)sender;
- (void)_createAddFilesPanel;
- (NSMutableArray *)filesForAdd;
- (void)filesForAddPopupClicked:(id)sender;
- (NSMutableArray *)filesForAddOfTypes:(NSArray*)fileTypes;
@end

View file

@ -30,6 +30,7 @@
#include "PCProject.h"
#include "PCProjectBrowser.h"
#include "PCServer.h"
#include "PCAddFilesPanel.h"
#include "PCLogController.h"
@ -78,8 +79,6 @@ static PCFileManager *_mgr = nil;
if (addFilesPanel)
{
RELEASE(addFilesPanel);
RELEASE(fileTypePopup);
RELEASE(fileTypeAccessaryView);
}
[super dealloc];
@ -337,38 +336,7 @@ static PCFileManager *_mgr = nil;
}
// --- "Add Files..." panel
- (void)_createAddFilesPanel
{
if (addFilesPanel == nil)
{
NSRect fr = NSMakeRect(20,30,160,21);
PCProject *project = [projectManager activeProject];
// File type popup
fileTypePopup = [[NSPopUpButton alloc] initWithFrame:fr pullsDown:NO];
[fileTypePopup setRefusesFirstResponder:YES];
[fileTypePopup setAutoenablesItems:NO];
[fileTypePopup setTarget:self];
[fileTypePopup setAction:@selector(filesForAddPopupClicked:)];
[fileTypePopup addItemsWithTitles:[project rootCategories]];
[fileTypePopup selectItemAtIndex:0];
fileTypeAccessaryView = [[NSBox alloc] init];
[fileTypeAccessaryView setTitle:@"File Types"];
[fileTypeAccessaryView setTitlePosition:NSAtTop];
[fileTypeAccessaryView setBorderType:NSGrooveBorder];
[fileTypeAccessaryView addSubview:fileTypePopup];
[fileTypeAccessaryView sizeToFit];
[fileTypeAccessaryView setAutoresizingMask:NSViewMinXMargin
| NSViewMaxXMargin];
// Panel
addFilesPanel = [NSOpenPanel openPanel];
[addFilesPanel setAllowsMultipleSelection:YES];
[addFilesPanel setDelegate:self];
}
}
- (NSMutableArray *)filesForAdd
- (NSMutableArray *)filesForAddOfTypes:(NSArray*)fileTypes
{
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
NSString *lastOpenDir = [ud objectForKey:@"LastOpenDirectory"];
@ -376,28 +344,14 @@ static PCFileManager *_mgr = nil;
NSString *selectedCategory = nil;
int retval;
[self _createAddFilesPanel];
[addFilesPanel setAccessoryView:fileTypeAccessaryView];
if (addFilesPanel == nil)
{
addFilesPanel = [PCAddFilesPanel addFilesPanel];
[addFilesPanel setDelegate:self];
}
[addFilesPanel setCategories:[project rootCategories]];
selectedCategory = [[project projectBrowser] nameOfSelectedCategory];
if ([selectedCategory isEqualToString:@"Subprojects"])
{
[addFilesPanel setCanChooseFiles:NO];
[addFilesPanel setCanChooseDirectories:YES];
}
else if ([selectedCategory isEqualToString:@"Other Resources"])
{
[addFilesPanel setCanChooseFiles:YES];
[addFilesPanel setCanChooseDirectories:YES];
}
else
{
[addFilesPanel setCanChooseFiles:YES];
[addFilesPanel setCanChooseDirectories:NO];
}
[fileTypePopup selectItemWithTitle:selectedCategory];
[self filesForAddPopupClicked:self];
[addFilesPanel selectCategory:selectedCategory];
if (!lastOpenDir)
{
@ -406,7 +360,7 @@ static PCFileManager *_mgr = nil;
retval = [addFilesPanel runModalForDirectory:lastOpenDir
file:nil
types:nil];
types:fileTypes];
if (retval == NSOKButton)
{
[ud setObject:[addFilesPanel directory] forKey:@"LastOpenDirectory"];
@ -416,18 +370,27 @@ static PCFileManager *_mgr = nil;
return nil;
}
- (void)filesForAddPopupClicked:(id)sender
// ============================================================================
// ==== PCAddFilesPanel delegate
// ============================================================================
- (void)categoryChangedTo:(NSString *)category
{
NSString *fileType = [fileTypePopup titleOfSelectedItem];
PCProject *project = [projectManager activeProject];
NSArray *fileTypes = nil;
PCProjectBrowser *browser = [project projectBrowser];
NSString *path = [browser path];
[addFilesPanel setTitle:[NSString stringWithFormat:@"Add %@",fileType]];
[addFilesPanel setTitle:[NSString stringWithFormat:@"Add %@",category]];
if ([fileType isEqualToString:@"Interfaces"])
{
[addFilesPanel setCanChooseDirectories:YES];
}
[addFilesPanel display];
fileTypes = [project
fileTypesForCategoryKey:[project keyForCategory:category]];
[addFilesPanel setFileTypes:fileTypes];
// Set project browser path
path = [path stringByDeletingLastPathComponent];
path = [path stringByAppendingPathComponent:category];
[browser setPath:path];
}
// ============================================================================
@ -441,22 +404,21 @@ static PCFileManager *_mgr = nil;
BOOL isDir;
PCProject *project = nil;
NSArray *fileTypes = nil;
NSString *fileType = nil;
NSString *category = nil;
NSString *categoryKey = nil;
[fileManager fileExistsAtPath:filename isDirectory:&isDir];
if ([[filename pathExtension] isEqualToString:@"gorm"])
{
NSLog(@"GORM file: %@", filename);
isDir = NO;
}
if (sender == addFilesPanel && !isDir)
{
project = [projectManager activeProject];
fileType = [fileTypePopup titleOfSelectedItem];
categoryKey = [project keyForCategory:fileType];
category = [addFilesPanel selectedCategory];
categoryKey = [project keyForCategory:category];
fileTypes = [project fileTypesForCategoryKey:categoryKey];
// Wrong file extension
if (fileTypes
@ -465,10 +427,8 @@ static PCFileManager *_mgr = nil;
return NO;
}
// File is already in project
NSLog(@"file: %@ type: %@ fileTypes: %@", filename, fileType, fileTypes);
if (![project doesAcceptFile:filename forKey:categoryKey])
{
NSLog(@"Don't show: %@", filename);
return NO;
}
}

View file

@ -620,40 +620,69 @@ NSString
- (NSString *)projectFileFromFile:(NSString *)file forKey:(NSString *)type
{
NSMutableString *projectFile = nil;
NSString *path = nil;
NSString *projectFile = nil;
NSString *_path = nil;
NSMutableArray *_pathComponents = nil;
NSString *_file = nil;
NSArray *subprojects = [projectDict objectForKey:PCSubprojects];
NSRange pathRange;
NSRange slashRange;
NSString *spDir = nil;
path = [file stringByDeletingLastPathComponent];
pathRange = [path rangeOfString:projectPath];
_path = [file stringByDeletingLastPathComponent];
_pathComponents = [[_path pathComponents] mutableCopy];
_file = [file lastPathComponent];
if (pathRange.length)
// Remove "lib" prefix from library name
if ([type isEqualToString:PCLibraries])
{
slashRange.location = pathRange.length;
slashRange.length = 1;
_file = [_file stringByDeletingPathExtension];
_file = [_file substringFromIndex:3];
}
if (pathRange.length
&& slashRange.location != [path length]
&& [[path substringWithRange:slashRange] isEqualToString:@"/"])
pathRange = [_path rangeOfString:projectPath];
// File is located in project's directory tree
if (pathRange.length && ![type isEqualToString:PCLibraries])
{
pathRange.length++;
projectFile = [NSMutableString stringWithString:file];
[projectFile deleteCharactersInRange:pathRange];
int i;
for (i = 0; i < [subprojects count]; i++)
{
spDir = [[subprojects objectAtIndex:i]
stringByAppendingPathExtension:@"subproj"];
if ([_pathComponents containsObject:spDir])
{
break;
}
spDir = nil;
}
}
if (spDir != nil)
{
while (![[_pathComponents objectAtIndex:0] isEqualToString:spDir])
{
[_pathComponents removeObjectAtIndex:0];
}
}
else
{
projectFile = [NSMutableString stringWithString:[file lastPathComponent]];
[_pathComponents removeAllObjects];
}
if ([type isEqualToString:PCLibraries])
// Construct project file name
if ([_pathComponents count])
{
[projectFile deleteCharactersInRange:NSMakeRange(0,3)];
projectFile =
(NSMutableString*)[projectFile stringByDeletingPathExtension];
projectFile = [NSString pathWithComponents:_pathComponents];
projectFile = [projectFile stringByAppendingPathComponent:_file];
}
else
{
projectFile = [NSString stringWithString:_file];
}
RELEASE(_pathComponents);
return projectFile;
}
@ -682,7 +711,6 @@ NSString
while ((key = [keyEnum nextObject]))
{
projectFiles = [projectDict objectForKey:key];
NSLog(@"KEY: %@ Files: %@ file: %@", key, projectFiles, pFile);
if ([projectFiles containsObject:pFile])
{
return NO;
@ -778,6 +806,17 @@ NSString
NSArray *types = [projectDict objectForKey:type];
NSMutableArray *projectFiles = [NSMutableArray arrayWithArray:types];
if ([type isEqualToString:PCLibraries])
{
NSMutableArray *searchLibs = [NSMutableArray arrayWithCapacity:1];
NSString *path = nil;
path = [[files objectAtIndex:0] stringByDeletingLastPathComponent];
[searchLibs setArray:[projectDict objectForKey:PCSearchLibs]];
[searchLibs addObject:path];
[self setProjectDictObject:searchLibs forKey:PCSearchLibs notify:yn];
}
enumerator = [files objectEnumerator];
while ((file = [enumerator nextObject]))
{
@ -1336,10 +1375,11 @@ NSString
return YES;
}
if ([[projectDict objectForKey:PCSubprojects] containsObject:listEntry])
{
return YES;
}
if ([[projectDict objectForKey:PCSubprojects] containsObject:listEntry]
&& [[projectBrowser nameOfSelectedCategory] isEqualToString:@"Subprojects"])
{
return YES;
}
return NO;
}

View file

@ -383,7 +383,8 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification";
categoryPath:[browser path]
windowed:YES];
}
else if ([[NSWorkspace sharedWorkspace] openFile:filePath] == NO)
else if (![[self nameOfSelectedCategory] isEqualToString:@"Libraries"]
&& [[NSWorkspace sharedWorkspace] openFile:filePath] == NO)
{
NSRunAlertPanel(@"Attention!",
@"Could not open %@.",
@ -396,7 +397,7 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification";
{
[[project projectManager] addSubproject];
}
else
else
{
[[project projectManager] addProjectFiles];
}

View file

@ -115,6 +115,13 @@
name:PCActiveProjectDidChangeNotification
object:nil];
// Track project dictionary changing
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(updateValues:)
name:PCProjectDictDidChangeNotification
object:nil];
[self inspectorPopupDidChange:inspectorPopup];
return self;

View file

@ -724,12 +724,17 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
NSMutableArray *files = nil;
NSString *file = nil;
NSString *projectFile = nil;
NSArray *fileTypes = [project fileTypesForCategoryKey:categoryKey];
files = [fileManager filesForAdd];
files = [fileManager filesForAddOfTypes:fileTypes];
/* PCLogInfo(self, @"[addProjectFiles] %@ to category: %@ of project %@",
files, categoryKey, [activeProject projectName]);*/
// Category may be changed
category = [[project projectBrowser] nameOfSelectedCategory];
categoryKey = [activeProject keyForCategory:category];
// No files was selected
if (!files)
{
@ -1239,7 +1244,8 @@ NSString *PCActiveProjectDidChangeNotification = @"PCActiveProjectDidChange";
NSString *spName = nil;
int i;
files = [fileManager filesForAdd];
files = [fileManager
filesForAddOfTypes:[NSArray arrayWithObjects:@"subproj",nil]];
// Validate if it real projects
for (i = 0; i < [files count]; i++)

View file

@ -352,6 +352,11 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification";
[docClassField setBackgroundColor:[NSColor lightGrayColor]];
[docClassField setTextColor:[NSColor darkGrayColor]];
[docClassField setEditable:NO];
// Columns
[docTypesList removeTableColumn:nameColumn];
[docTypesList removeTableColumn:roleColumn];
[docTypesList removeTableColumn:classColumn];
if (![docBased isEqualToString:@"NO"])
{
@ -375,7 +380,7 @@ NSString *PCITextFieldGetFocus = @"PCITextFieldGetFocusNotification";
[entry setObject:@"Editor" forKey:@"NSRole"];
[entry setObject:@"NSDocument" forKey:@"NSDocumentClass"];
if (selectedRow >= 0)
if (selectedRow >= 0 && [docTypesItems count] > 0)
{
[docTypesItems insertObject:entry atIndex:selectedRow + 1];
row = selectedRow + 1;

View file

@ -2,40 +2,10 @@
"## Comment" = "Do NOT change this file, Gorm maintains it";
FirstResponder = {
Actions = (
"alignLeft:",
"capitalizeWord:",
"complete:",
"cut:",
"deleteToBeginningOfLine:",
"deleteToMark:",
"deselectAll:",
"indent:",
"makeKeyAndOrderFront:",
"moveBackwardAndModifySelection:",
"moveForwardAndModifySelection:",
"moveToBeginningOfLine:",
"moveToEndOfParagraph:",
"moveWordBackwardAndModifySelection:",
"ok:",
"orderFront:",
"orderFrontStandardAboutPanel:",
"pageUp:",
"pasteFont:",
"performZoom:",
"runPageLayout:",
"saveDocumentAs:",
"scrollPageDown:",
"selectLine:",
"selectText:",
"showGuessPanel:",
"subscript:",
"takeFloatValueFrom:",
"terminate:",
"toggleRuler:",
"transposeWords:",
"unhide:",
"useAllLigatures:",
"zoom:",
"setAppClass:",
"setFile:",
"clearFile:",
@ -76,7 +46,6 @@
addDocTypeButton,
removeDocTypeButton,
docBasedAppButton,
docTypesScroll,
docTypeLabel,
docTypeField,
docNameLabel,
@ -88,7 +57,14 @@
docRoleLabel,
docRoleField,
docClassLabel,
docClassField
docClassField,
docTypesList,
typeColumn,
nameColumn,
extensionsColumn,
iconColumn,
roleColumn,
classColumn
);
Super = NSObject;
};

View file

@ -25,7 +25,7 @@
PROJECT_AUTHORS = ();
PROJECT_CREATOR = "";
PROJECT_DESCRIPTION = "No description avaliable!";
PROJECT_DOCUMENTEXTENSIONS = ();
PROJECT_DOCUMENTTYPES = ();
PROJECT_GROUP = "No group avaliable!";
PROJECT_SUMMARY = "No summary avaliable!";
PROJECT_RELEASE = "0.1";