mirror of
https://github.com/gnustep/apps-projectcenter.git
synced 2025-02-19 01:51:09 +00:00
Rewriting the entire editor code. Hence introduced a PCEditorController and
cleaned up the PCServer class. Every project now has a controller which controls all editors. Editors itself use an editor view to display the files or external editors. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@12386 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d4bd4d3637
commit
7c264a098c
17 changed files with 355 additions and 180 deletions
|
@ -61,7 +61,8 @@ ProjectEditor.h \
|
|||
ProjectType.h \
|
||||
Server.h \
|
||||
PCSplitView.h \
|
||||
PCEditor.h
|
||||
PCEditor.h \
|
||||
PCEditorController.h
|
||||
|
||||
#
|
||||
|
||||
|
@ -80,7 +81,8 @@ PCProjectDebugger.m \
|
|||
PCProjectManager.m \
|
||||
PCServer.m \
|
||||
PCSplitView.m \
|
||||
PCEditor.m
|
||||
PCEditor.m \
|
||||
PCEditorController.m
|
||||
|
||||
#
|
||||
|
||||
|
|
|
@ -56,6 +56,3 @@
|
|||
- (BOOL)browser:(NSBrowser *)sender selectCellWithString:(NSString *)title inColumn:(int)column;
|
||||
|
||||
@end
|
||||
|
||||
extern NSString *FileShouldOpenNotification;
|
||||
|
||||
|
|
|
@ -28,8 +28,6 @@
|
|||
#import "PCProject.h"
|
||||
#import "PCFileManager.h"
|
||||
|
||||
NSString *FileShouldOpenNotification = @"FileShouldOpenNotification";
|
||||
|
||||
@implementation PCBrowserController
|
||||
|
||||
- (void)dealloc
|
||||
|
@ -52,33 +50,36 @@ NSString *FileShouldOpenNotification = @"FileShouldOpenNotification";
|
|||
|
||||
- (void)doubleClick:(id)sender
|
||||
{
|
||||
if ([sender selectedColumn] != 0) {
|
||||
if ([sender selectedColumn] != 0)
|
||||
{
|
||||
NSString *category = [[[browser path] componentsSeparatedByString:@"/"] objectAtIndex:1];
|
||||
NSString *k = [[project rootCategories] objectForKey:category];
|
||||
|
||||
if ([k isEqualToString:PCClasses] ||
|
||||
[k isEqualToString:PCHeaders] ||
|
||||
[k isEqualToString:PCOtherSources]) {
|
||||
[k isEqualToString:PCOtherSources])
|
||||
{
|
||||
NSString *projectPath = [project projectPath];
|
||||
NSString *fn = [self nameOfSelectedFile];
|
||||
NSString *file = [projectPath stringByAppendingPathComponent:fn];
|
||||
NSDictionary *ui =[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
file,@"FilePathKey",nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:FileShouldOpenNotification object:self userInfo:ui];
|
||||
[[[project editorController] editorForFile:file] show];
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
NSString *fi;
|
||||
NSString *sf = [self nameOfSelectedFile];
|
||||
|
||||
fi = [[project projectPath] stringByAppendingPathComponent:sf];
|
||||
|
||||
if([[NSWorkspace sharedWorkspace] openFile:fi] == NO) {
|
||||
if([[NSWorkspace sharedWorkspace] openFile:fi] == NO)
|
||||
{
|
||||
NSRunAlertPanel(@"Attention!",@"Could not open %@.",@"OK",nil,nil,fi);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
[[PCFileManager fileManager] showAddFileWindow];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
defaults under the key BundlePaths.
|
||||
|
||||
*/
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
#import "PreferenceController.h"
|
||||
|
@ -60,17 +61,6 @@
|
|||
- (NSArray *)loadedBundles;
|
||||
// Returns all loaded ProjectCenter bundles.
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// BundleLoader
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
- (BOOL)registerProjectSubmenu:(NSMenu *)menu;
|
||||
- (BOOL)registerFileSubmenu:(NSMenu *)menu;
|
||||
- (BOOL)registerToolsSubmenu:(NSMenu *)menu;
|
||||
- (BOOL)registerPrefController:(id<PreferenceController>)prefs;
|
||||
- (BOOL)registerEditor:(id<ProjectEditor>)anEditor;
|
||||
- (BOOL)registerDebugger:(id<ProjectDebugger>)aDebugger;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSObject (BundleLoaderDelegates)
|
||||
|
|
|
@ -45,18 +45,21 @@
|
|||
NSLog([NSString stringWithFormat:@"Loading bundle %@...",path]);
|
||||
#endif// DEBUG
|
||||
|
||||
if ((bundle = [NSBundle bundleWithPath:path])) {
|
||||
if ((bundle = [NSBundle bundleWithPath:path]))
|
||||
{
|
||||
[loadedBundles addObject:bundle];
|
||||
|
||||
#ifdef DEBUG
|
||||
NSLog([NSString stringWithFormat:@"Bundle %@ successfully loaded!",path]);
|
||||
#endif// DEBUG
|
||||
|
||||
if (delegate && [delegate respondsToSelector:@selector(bundleLoader: didLoadBundle:)]) {
|
||||
if (delegate && [delegate respondsToSelector:@selector(bundleLoader: didLoadBundle:)])
|
||||
{
|
||||
[delegate bundleLoader:self didLoadBundle:bundle];
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
NSRunAlertPanel(@"Attention!",@"Could not load %@!",@"OK",nil,nil,path);
|
||||
}
|
||||
}
|
||||
|
@ -101,14 +104,17 @@
|
|||
NSArray *dir;
|
||||
NSString *path = [[NSUserDefaults standardUserDefaults] objectForKey:BundlePaths];
|
||||
|
||||
if (!path || [path isEqualToString:@""]) {
|
||||
if (!path || [path isEqualToString:@""])
|
||||
{
|
||||
NSDictionary *env = [[NSProcessInfo processInfo] environment];
|
||||
NSString *prefix = [env objectForKey:@"GNUSTEP_SYSTEM_ROOT"];
|
||||
|
||||
if (prefix && ![prefix isEqualToString:@""]) {
|
||||
if (prefix && ![prefix isEqualToString:@""])
|
||||
{
|
||||
path =[prefix stringByAppendingPathComponent:@"Library/ProjectCenter"];
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
path = [NSString stringWithString:@"/usr/GNUstep/System/Library/ProjectCenter"];
|
||||
}
|
||||
|
||||
|
@ -116,22 +122,29 @@
|
|||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
}
|
||||
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
|
||||
[NSException raise:@"PCBundleLoaderPathException" format:@"No valid bundle path specified:\n%@",path];
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:path])
|
||||
{
|
||||
[NSException raise:@"PCBundleLoaderPathException"
|
||||
format:@"No valid bundle path specified:\n%@",path];
|
||||
return;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
else {
|
||||
else
|
||||
{
|
||||
NSLog([NSString stringWithFormat:@"Loading bundles at %@",path]);
|
||||
}
|
||||
#endif// DEBUG
|
||||
|
||||
dir = [[NSFileManager defaultManager] directoryContentsAtPath:path];
|
||||
enumerator = [dir objectEnumerator];
|
||||
while (bundleName = [enumerator nextObject]) {
|
||||
if ([[bundleName pathExtension] isEqualToString:@"bundle"]) {
|
||||
NSString *fullPath = [NSString stringWithFormat:@"%@/%@",path,bundleName];
|
||||
|
||||
|
||||
while (bundleName = [enumerator nextObject])
|
||||
{
|
||||
if ([[bundleName pathExtension] isEqualToString:@"bundle"])
|
||||
{
|
||||
NSString *fullPath;
|
||||
|
||||
fullPath = [NSString stringWithFormat:@"%@/%@",path,bundleName];
|
||||
[self loadAdditionalBundlesAt:fullPath];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
- (BOOL)isEmbedded;
|
||||
|
||||
- (NSWindow *)editorWindow;
|
||||
- (NSString *)path;
|
||||
|
||||
- (void)show;
|
||||
- (void)close;
|
||||
|
@ -44,5 +45,11 @@
|
|||
|
||||
@end
|
||||
|
||||
@interface NSObject (PCEditorDelegate )
|
||||
|
||||
- (void)editorDidClose:(id)sender;
|
||||
|
||||
@end
|
||||
|
||||
#endif // _PCEDITOR_H_
|
||||
|
||||
|
|
|
@ -63,6 +63,8 @@
|
|||
[scrollView setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)];
|
||||
|
||||
[window setContentView:scrollView];
|
||||
[window setDelegate:self];
|
||||
|
||||
RELEASE(scrollView);
|
||||
}
|
||||
|
||||
|
@ -113,6 +115,11 @@
|
|||
return window;
|
||||
}
|
||||
|
||||
- (NSString *)path
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
- (void)setEmbedded:(BOOL)yn
|
||||
{
|
||||
isEmbedded = yn;
|
||||
|
@ -136,13 +143,40 @@
|
|||
|
||||
- (void)close
|
||||
{
|
||||
NSLog(@"Closing editor for file %@",path);
|
||||
if( isEmbedded == NO && [window isDocumentEdited] )
|
||||
{
|
||||
BOOL ret;
|
||||
|
||||
[window makeKeyAndOrderFront:self];
|
||||
|
||||
ret = NSRunAlertPanel(@"Edited File!",
|
||||
@"Should the file be saved before closing?",
|
||||
@"Yes",@"No",nil);
|
||||
|
||||
if( ret == YES )
|
||||
{
|
||||
// SAVE
|
||||
}
|
||||
|
||||
[window setDocumentEdited:NO];
|
||||
}
|
||||
else if( isEmbedded )
|
||||
{
|
||||
}
|
||||
|
||||
[window performClose:self];
|
||||
|
||||
if( delegate && [delegate respondsToSelector:@selector(editorDidClose:)] )
|
||||
{
|
||||
[delegate editorDidClose:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)windowWillClose:(NSNotification *)aNotif
|
||||
{
|
||||
if( [[aNotif object] isEqual:window] )
|
||||
{
|
||||
[self close];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
55
PCLib/PCEditorController.h
Normal file
55
PCLib/PCEditorController.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* PCEditorController.h created by probert on 2002-02-02 15:28:33 +0000
|
||||
*
|
||||
* Project ProjectCenter
|
||||
*
|
||||
* Created with ProjectCenter - http://www.gnustep.org
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef _PCEDITORCONTROLLER_H_
|
||||
#define _PCEDITORCONTROLLER_H_
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class PCProject;
|
||||
@class PCEditor;
|
||||
|
||||
@interface PCEditorController : NSObject
|
||||
{
|
||||
PCProject *project;
|
||||
NSMutableDictionary *editorDict;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// ==== Class Methods
|
||||
// ===========================================================================
|
||||
|
||||
+ (void)openFileInEditor:(NSString *)path;
|
||||
|
||||
// ===========================================================================
|
||||
// ==== Initialisation
|
||||
// ===========================================================================
|
||||
|
||||
- (id)init;
|
||||
|
||||
- (void)dealloc;
|
||||
|
||||
// ===========================================================================
|
||||
// ==== Project and Editor handling
|
||||
// ===========================================================================
|
||||
|
||||
- (void)setProject:(PCProject *)aProject;
|
||||
|
||||
- (PCEditor *)editorForFile:(NSString *)path;
|
||||
- (NSArray *)allEditors;
|
||||
|
||||
- (void)closeAllEditors;
|
||||
|
||||
- (void)editorDidClose:(id)sender;
|
||||
|
||||
@end
|
||||
|
||||
#endif // _PCEDITORCONTROLLER_H_
|
||||
|
138
PCLib/PCEditorController.m
Normal file
138
PCLib/PCEditorController.m
Normal file
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* PCEditorController.m created by probert on 2002-02-02 15:28:31 +0000
|
||||
*
|
||||
* Project ProjectCenter
|
||||
*
|
||||
* Created with ProjectCenter - http://www.gnustep.org
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#import "PCEditorController.h"
|
||||
#import "PCEditor.h"
|
||||
#import "PCProject.h"
|
||||
#import "ProjectCenter.h"
|
||||
|
||||
@implementation PCEditorController
|
||||
|
||||
// ===========================================================================
|
||||
// ==== Class Methods
|
||||
// ===========================================================================
|
||||
|
||||
+ (void)openFileInEditor:(NSString *)path
|
||||
{
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
if([[ud objectForKey:ExternalEditor] isEqualToString:@"YES"])
|
||||
{
|
||||
NSTask *editorTask;
|
||||
NSMutableArray *args;
|
||||
NSString *editor = [ud objectForKey:Editor];
|
||||
NSArray *ea = [editor componentsSeparatedByString: @" "];
|
||||
|
||||
args = [NSMutableArray arrayWithArray:ea];
|
||||
editorTask = [[NSTask alloc] init];
|
||||
[editorTask setLaunchPath:[args objectAtIndex: 0]];
|
||||
[args removeObjectAtIndex: 0];
|
||||
[args addObject:path];
|
||||
[editorTask setArguments:args];
|
||||
|
||||
AUTORELEASE( editorTask );
|
||||
[editorTask launch];
|
||||
}
|
||||
else
|
||||
{
|
||||
PCEditor *editor;
|
||||
|
||||
editor = [[PCEditor alloc] initWithPath:path];
|
||||
[editor show];
|
||||
}
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// ==== Initialisation
|
||||
// ===========================================================================
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if((self = [super init]))
|
||||
{
|
||||
editorDict = [[NSMutableDictionary alloc] init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
RELEASE( editorDict );
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
// ==== Project and Editor handling
|
||||
// ===========================================================================
|
||||
|
||||
- (void)setProject:(PCProject *)aProject
|
||||
{
|
||||
project = aProject;
|
||||
}
|
||||
|
||||
- (PCEditor *)editorForFile:(NSString *)path
|
||||
{
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
if([[ud objectForKey:ExternalEditor] isEqualToString:@"YES"])
|
||||
{
|
||||
[PCEditorController openFileInEditor:path];
|
||||
}
|
||||
else
|
||||
{
|
||||
PCEditor *editor;
|
||||
|
||||
if( editor = [editorDict objectForKey:path] )
|
||||
{
|
||||
return editor;
|
||||
}
|
||||
else
|
||||
{
|
||||
editor = [[PCEditor alloc] initWithPath:path];
|
||||
|
||||
[editor setDelegate:self];
|
||||
|
||||
[editorDict setObject:editor forKey:path];
|
||||
//RELEASE(editor);
|
||||
|
||||
return editor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray *)allEditors
|
||||
{
|
||||
return [editorDict allValues];
|
||||
}
|
||||
|
||||
- (void)closeAllEditors
|
||||
{
|
||||
NSEnumerator *enumerator = [editorDict keyEnumerator];
|
||||
PCEditor *editor;
|
||||
NSString *key;
|
||||
|
||||
while(( key = [enumerator nextObject] ))
|
||||
{
|
||||
editor = [editorDict objectForKey:key];
|
||||
|
||||
[editor close];
|
||||
}
|
||||
[editorDict removeAllObjects];
|
||||
}
|
||||
|
||||
- (void)editorDidClose:(id)sender
|
||||
{
|
||||
PCEditor *editor = (PCEditor*)sender;
|
||||
|
||||
[editorDict removeObjectForKey:[editor path]];
|
||||
}
|
||||
|
||||
@end
|
|
@ -50,4 +50,6 @@
|
|||
- (void)colouriseComments;
|
||||
- (void)colouriseCPPComments;
|
||||
|
||||
- (void)keyDown: (NSEvent *)anEvent;
|
||||
|
||||
@end
|
||||
|
|
|
@ -41,7 +41,8 @@ static BOOL isInitialised = NO;
|
|||
|
||||
- (id)initWithFrame:(NSRect)frameRect
|
||||
{
|
||||
if ((self = [super initWithFrame:frameRect])) {
|
||||
if ((self = [super initWithFrame:frameRect]))
|
||||
{
|
||||
|
||||
/*
|
||||
* Should move that to initialize...
|
||||
|
@ -357,6 +358,16 @@ static BOOL isInitialised = NO;
|
|||
}
|
||||
}
|
||||
|
||||
- (void)keyDown: (NSEvent *)anEvent
|
||||
{
|
||||
if( [[self window] isDocumentEdited] == NO )
|
||||
{
|
||||
[[self window] setDocumentEdited:YES];
|
||||
}
|
||||
|
||||
[super keyDown:anEvent];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
|
|
@ -106,6 +106,7 @@ static NSString * const PCBuildTool = @"BUILDTOOL";
|
|||
|
||||
@class PCProjectBuilder;
|
||||
@class PCProjectDebugger;
|
||||
@class PCEditorController;
|
||||
|
||||
@interface PCProject : NSObject
|
||||
{
|
||||
|
@ -116,6 +117,7 @@ static NSString * const PCBuildTool = @"BUILDTOOL";
|
|||
|
||||
PCProjectBuilder *projectBuilder;
|
||||
PCProjectDebugger *projectDebugger;
|
||||
PCEditorController *editorController;
|
||||
NSBox *box;
|
||||
|
||||
id projectAttributeInspectorView;
|
||||
|
@ -167,6 +169,8 @@ static NSString * const PCBuildTool = @"BUILDTOOL";
|
|||
|
||||
- (Class)principalClass;
|
||||
|
||||
- (PCEditorController*)editorController;
|
||||
|
||||
//=============================================================================
|
||||
// ==== Delegate and manager
|
||||
//=============================================================================
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#import "ProjectCenter.h"
|
||||
#import "PCProjectBuilder.h"
|
||||
#import "PCSplitView.h"
|
||||
#import "PCEditorController.h"
|
||||
|
||||
#if defined(GNUSTEP)
|
||||
#import <AppKit/IMLoading.h>
|
||||
|
@ -399,15 +400,19 @@
|
|||
|
||||
@implementation PCProject
|
||||
|
||||
//===========================================================================================
|
||||
//==============================================================================
|
||||
// ==== Init and free
|
||||
//===========================================================================================
|
||||
//==============================================================================
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
if ((self = [super init]))
|
||||
{
|
||||
buildOptions = [[NSMutableDictionary alloc] init];
|
||||
[self _initUI];
|
||||
|
||||
editorController = [[PCEditorController alloc] init];
|
||||
[editorController setProject:self];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -416,7 +421,8 @@
|
|||
{
|
||||
NSAssert(dict,@"No valid project dictionary!");
|
||||
|
||||
if ((self = [self init])) {
|
||||
if ((self = [self init]))
|
||||
{
|
||||
if ([[path lastPathComponent] isEqualToString:@"PC.project"]) {
|
||||
projectPath = [[path stringByDeletingLastPathComponent] copy];
|
||||
}
|
||||
|
@ -466,13 +472,14 @@
|
|||
RELEASE(changeFileNameButton);
|
||||
|
||||
RELEASE(box);
|
||||
RELEASE(editorController);
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
//===========================================================================================
|
||||
//==============================================================================
|
||||
// ==== Accessor methods
|
||||
//===========================================================================================
|
||||
//==============================================================================
|
||||
|
||||
- (id)browserController
|
||||
{
|
||||
|
@ -534,9 +541,14 @@
|
|||
return [self class];
|
||||
}
|
||||
|
||||
//===========================================================================================
|
||||
- (PCEditorController*)editorController
|
||||
{
|
||||
return editorController;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// ==== Delegate and manager
|
||||
//===========================================================================================
|
||||
//==============================================================================
|
||||
|
||||
- (id)delegate
|
||||
{
|
||||
|
@ -548,7 +560,7 @@
|
|||
delegate = aDelegate;
|
||||
}
|
||||
|
||||
- (void)setProjectBuilder:(id<ProjectBuilder>)aBuilder
|
||||
- (void)setProjectBuilder:(id<ProjectBuilder,NSObject>)aBuilder
|
||||
{
|
||||
AUTORELEASE(projectManager);
|
||||
projectManager = RETAIN(aBuilder);
|
||||
|
@ -559,9 +571,9 @@
|
|||
return projectManager;
|
||||
}
|
||||
|
||||
//===========================================================================================
|
||||
//==============================================================================
|
||||
// ==== To be overriden
|
||||
//===========================================================================================
|
||||
//==============================================================================
|
||||
|
||||
- (Class)builderClass
|
||||
{
|
||||
|
@ -655,7 +667,7 @@
|
|||
|
||||
if ([type isEqualToString:PCLibraries]) {
|
||||
[newFile deleteCharactersInRange:NSMakeRange(0,3)];
|
||||
newFile = [newFile stringByDeletingPathExtension];
|
||||
newFile = (NSMutableString*)[newFile stringByDeletingPathExtension];
|
||||
}
|
||||
|
||||
if ([files containsObject:newFile]) {
|
||||
|
@ -807,7 +819,6 @@
|
|||
- (BOOL)save
|
||||
{
|
||||
BOOL ret = NO;
|
||||
//NSString *file = [projectPath stringByAppendingPathComponent:@"PC.project"];
|
||||
NSString *file = [[projectPath stringByAppendingPathComponent:projectName] stringByAppendingPathExtension:@"pcproj"];
|
||||
NSString *backup = [file stringByAppendingPathExtension:@"backup"];
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
|
@ -1237,17 +1248,22 @@
|
|||
{
|
||||
id object = [aNotification object];
|
||||
|
||||
if (object == buildTargetPanel) {
|
||||
if (object == buildTargetPanel)
|
||||
{
|
||||
}
|
||||
else if (object == [self projectWindow]) {
|
||||
if ([[self projectWindow] isDocumentEdited]) {
|
||||
else if (object == [self projectWindow])
|
||||
{
|
||||
if ([[self projectWindow] isDocumentEdited])
|
||||
{
|
||||
if (NSRunAlertPanel(@"Project changed!",
|
||||
@"The project %@ has unsaved files! Should they be saved before closing?",
|
||||
@"The project %@ has been edited! Should it be saved before closing?",
|
||||
@"Yes", @"No", nil,[self projectName]))
|
||||
{
|
||||
[self save];
|
||||
}
|
||||
}
|
||||
|
||||
[editorController closeAllEditors];
|
||||
|
||||
// The PCProjectController is our delegate!
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:browserController];
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#import "PCProjectManager.h"
|
||||
#import "PCEditorController.h"
|
||||
#import "ProjectCenter.h"
|
||||
|
||||
#if defined(GNUSTEP)
|
||||
|
@ -130,8 +131,8 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange";
|
|||
|
||||
- (void)dealloc
|
||||
{
|
||||
[rootBuildPath release];
|
||||
[loadedProjects release];
|
||||
RELEASE(rootBuildPath);
|
||||
RELEASE(loadedProjects);
|
||||
|
||||
if( [saveTimer isValid] )
|
||||
{
|
||||
|
@ -142,9 +143,9 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange";
|
|||
|
||||
if (_needsReleasing)
|
||||
{
|
||||
[inspector release];
|
||||
[inspectorView release];
|
||||
[inspectorPopup release];
|
||||
RELEASE(inspector);
|
||||
RELEASE(inspectorView);
|
||||
RELEASE(inspectorPopup);
|
||||
}
|
||||
|
||||
[super dealloc];
|
||||
|
@ -265,12 +266,14 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange";
|
|||
|
||||
- (PCProject *)loadProjectAt:(NSString *)aPath
|
||||
{
|
||||
if (delegate && [delegate respondsToSelector:@selector(projectTypes)]) {
|
||||
NSDictionary *builders = [delegate projectTypes];
|
||||
NSEnumerator *enumerator = [builders keyEnumerator];
|
||||
NSString *builderKey;
|
||||
if (delegate && [delegate respondsToSelector:@selector(projectTypes)])
|
||||
{
|
||||
NSDictionary *builders = [delegate projectTypes];
|
||||
NSEnumerator *enumerator = [builders keyEnumerator];
|
||||
NSString *builderKey;
|
||||
|
||||
while (builderKey = [enumerator nextObject]) {
|
||||
while (builderKey = [enumerator nextObject])
|
||||
{
|
||||
id<ProjectType> concretBuilder;
|
||||
PCProject *project;
|
||||
|
||||
|
@ -280,19 +283,17 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange";
|
|||
|
||||
concretBuilder = [NSClassFromString([builders objectForKey:builderKey]) sharedCreator];
|
||||
|
||||
if ((project = [concretBuilder openProjectAt:aPath])) {
|
||||
if ((project = [concretBuilder openProjectAt:aPath]))
|
||||
{
|
||||
[[project projectWindow] center];
|
||||
|
||||
return project;
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
else {
|
||||
NSLog(@"No project manager delegate available!");
|
||||
}
|
||||
#endif // DEBUG
|
||||
|
||||
|
||||
NSRunAlertPanel(@"Loading Project Failed!",@"Could not load project '%@'!",@"OK",nil,nil,aPath);
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
@ -466,7 +467,7 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange";
|
|||
key = [path stringByAppendingPathComponent:projectName];
|
||||
key = [key stringByAppendingPathExtension:@"pcproj"];
|
||||
|
||||
currentProject = [[loadedProjects objectForKey:key] retain];
|
||||
currentProject = RETAIN( [loadedProjects objectForKey:key] );
|
||||
|
||||
if( !currentProject )
|
||||
{
|
||||
|
@ -482,7 +483,7 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange";
|
|||
[inspector performClose:self];
|
||||
}
|
||||
|
||||
AUTORELEASE(currentProject);
|
||||
AUTORELEASE( currentProject );
|
||||
}
|
||||
|
||||
- (void)closeProject
|
||||
|
@ -498,11 +499,11 @@ NSString *ActiveProjectDidChangeNotification = @"ActiveProjectDidChange";
|
|||
{
|
||||
BOOL isDir;
|
||||
NSFileManager *fm = [NSFileManager defaultManager];
|
||||
NSDictionary *ui =[NSDictionary dictionaryWithObjectsAndKeys:path,@"FilePathKey", nil];
|
||||
|
||||
if ([fm fileExistsAtPath:path isDirectory:&isDir] && !isDir)
|
||||
if ([fm fileExistsAtPath:path isDirectory:&isDir] && !isDir)
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:FileShouldOpenNotification object:self userInfo:ui];
|
||||
[PCEditorController openFileInEditor:path];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,6 @@ extern NSString *PCProjectBuildDidStopNotification;
|
|||
@interface PCServer : NSObject <Server>
|
||||
{
|
||||
NSMutableArray *clients;
|
||||
NSMutableDictionary *editors;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -74,18 +73,6 @@ extern NSString *PCProjectBuildDidStopNotification;
|
|||
- (id)init;
|
||||
- (void)dealloc;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Miscellaneous
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
- (void)fileShouldBeOpened:(NSNotification *)aNotif;
|
||||
|
||||
- (void)openFileInExternalEditor:(NSString *)file;
|
||||
- (void)openFileInInternalEditor:(NSString *)file;
|
||||
|
||||
- (void)closeEditorForFile:(NSString *)file;
|
||||
- (void)closeAllEditors;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Server
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
@ -40,102 +40,17 @@
|
|||
if ((self = [super init]))
|
||||
{
|
||||
clients = [[NSMutableArray alloc] init];
|
||||
editors = [[NSMutableDictionary alloc] init];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fileShouldBeOpened:) name:FileShouldOpenNotification object:nil];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
|
||||
RELEASE(editors);
|
||||
RELEASE(clients);
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Miscellaneous
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
- (void)fileShouldBeOpened:(NSNotification *)aNotif
|
||||
{
|
||||
NSString *file = [[aNotif userInfo] objectForKey:@"FilePathKey"];
|
||||
|
||||
if ([[[NSUserDefaults standardUserDefaults] objectForKey:ExternalEditor] isEqualToString:@"YES"]) {
|
||||
[self openFileInExternalEditor:file];
|
||||
}
|
||||
else {
|
||||
[self openFileInInternalEditor:file];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)openFileInExternalEditor:(NSString *)file
|
||||
{
|
||||
NSTask *editorTask;
|
||||
NSMutableArray *args;
|
||||
NSUserDefaults *udef = [NSUserDefaults standardUserDefaults];
|
||||
NSString *editor = [udef objectForKey:Editor];
|
||||
|
||||
args = [NSMutableArray arrayWithArray:
|
||||
[editor componentsSeparatedByString: @" "]];
|
||||
|
||||
editorTask = [[[NSTask alloc] init] autorelease];
|
||||
[editorTask setLaunchPath:[args objectAtIndex: 0]];
|
||||
[args removeObjectAtIndex: 0];
|
||||
[args addObject:file];
|
||||
[editorTask setArguments:args];
|
||||
|
||||
[editorTask launch];
|
||||
}
|
||||
|
||||
- (void)openFileInInternalEditor:(NSString *)file
|
||||
{
|
||||
PCEditor *editor = nil;
|
||||
|
||||
if((editor = [editors objectForKey:file]))
|
||||
{
|
||||
[editor show];
|
||||
}
|
||||
else
|
||||
{
|
||||
editor = [[PCEditor alloc] initWithPath:file];
|
||||
|
||||
[editor setDelegate:self];
|
||||
[editors setObject:editor forKey:file];
|
||||
[editor show];
|
||||
|
||||
RELEASE(editor);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)closeEditorForFile:(NSString *)file
|
||||
{
|
||||
PCEditor *editor;
|
||||
|
||||
if((editor = [editors objectForKey:file]))
|
||||
{
|
||||
[editor close];
|
||||
[editors removeObjectForKey:file];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)closeAllEditors
|
||||
{
|
||||
NSEnumerator *enumerator = [editors keyEnumerator];
|
||||
PCEditor *editor;
|
||||
|
||||
while((editor = [enumerator nextObject]))
|
||||
{
|
||||
[editor close];
|
||||
}
|
||||
|
||||
[editors removeAllObjects];
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Server
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
PCProjectManager.m,
|
||||
PCServer.m,
|
||||
PCSplitView.m,
|
||||
PCEditor.m
|
||||
PCEditor.m,
|
||||
PCEditorController.m
|
||||
);
|
||||
COMPILEROPTIONS = "";
|
||||
CREATION_DATE = "";
|
||||
|
@ -42,7 +43,8 @@
|
|||
ProjectType.h,
|
||||
Server.h,
|
||||
PCSplitView.h,
|
||||
PCEditor.h
|
||||
PCEditor.h,
|
||||
PCEditorController.h
|
||||
);
|
||||
INSTALLDIR = "$(GNUSTEP_SYSTEM_ROOT)";
|
||||
LANGUAGE = English;
|
||||
|
|
Loading…
Reference in a new issue