Began to work on support for an integrated editor, thus much has been rewritten

related to editor handling. This is work in progress... Every PCProject
component now has to conform to the ProjectComponent protocol.
Syntax highlighting is disabled for now, this will undergo a major rewrite soon.
Furthermore I separated the component handling stuff from the main class file
and put it into PCProject+ComponentHandling.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@12499 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Philippe C.D. Robert 2002-02-11 22:19:39 +00:00
parent 005848beb8
commit 396f6b9751
20 changed files with 625 additions and 275 deletions

View file

@ -64,7 +64,10 @@ PCSplitView.h \
PCEditor.h \
PCEditorController.h \
PCDefines.h \
PCTextFinder.h
PCTextFinder.h \
PCProjectEditor.h \
ProjectComponent.h \
PCProject+ComponentHandling.h
#
@ -85,7 +88,9 @@ PCServer.m \
PCSplitView.m \
PCEditor.m \
PCEditorController.m \
PCTextFinder.m
PCTextFinder.m \
PCProjectEditor.m \
PCProject+ComponentHandling.m
#

View file

@ -14,16 +14,19 @@
#import <AppKit/AppKit.h>
@class PCEditorView;
@class PCProjectEditor;
@interface PCEditor : NSObject
{
PCEditorView *view;
NSWindow *window;
PCEditorView *iView;
PCEditorView *eView;
NSTextStorage *storage;
NSWindow *window;
NSMutableString *path;
id delegate;
BOOL isEmbedded;
BOOL isEdited;
}
- (id)initWithPath:(NSString*)file;
@ -32,12 +35,12 @@
- (void)setDelegate:(id)aDelegate;
- (id)delegate;
- (void)setEmbedded:(BOOL)yn;
- (BOOL)isEmbedded;
- (NSWindow *)editorWindow;
- (NSString *)path;
- (void)setIsEdited:(BOOL)yn;
- (void)showInProjectEditor:(PCProjectEditor *)pe;
- (void)show;
- (void)close;

View file

@ -10,6 +10,7 @@
#import "PCEditor.h"
#import "PCEditorView.h"
#import "PCProjectEditor.h"
NSString *PCEditorDidBecomeKeyNotification=@"PCEditorDidBecomeKeyNotification";
NSString *PCEditorDidResignKeyNotification=@"PCEditorDidResignKeyNotification";
@ -25,6 +26,8 @@ NSString *PCEditorDidResignKeyNotification=@"PCEditorDidResignKeyNotification";
- (void)_initUI
{
NSScrollView *scrollView;
NSLayoutManager *lm;
NSTextContainer *tc;
unsigned int style = NSTitledWindowMask
| NSClosableWindowMask
| NSMiniaturizableWindowMask
@ -47,30 +50,65 @@ NSString *PCEditorDidResignKeyNotification=@"PCEditorDidResignKeyNotification";
scrollView = [[NSScrollView alloc] initWithFrame:rect];
// Now the text editing stuff
storage = [[NSTextStorage alloc] init];
lm = [[NSLayoutManager alloc] init];
[storage addLayoutManager:lm];
RELEASE(lm);
rect.origin.x = 0;
rect.origin.y = 0;
rect.size.height -= 24;
rect.size.width -= 4;
view = [[PCEditorView alloc] initWithFrame:rect];
[view setEditor:self];
tc = [[NSTextContainer alloc] initWithContainerSize:rect.size];
[lm addTextContainer:tc];
RELEASE(tc);
[view setMinSize: NSMakeSize (0, 0)];
[view setMaxSize:NSMakeSize(1e7, 1e7)];
[view setRichText:NO];
[view setEditable:YES];
[view setSelectable:YES];
[view setVerticallyResizable:YES];
[view setHorizontallyResizable:NO];
[view setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
[view setBackgroundColor:[NSColor whiteColor]];
[[view textContainer] setWidthTracksTextView:YES];
iView = [[PCEditorView alloc] initWithFrame:rect
textContainer:tc];
[iView setEditor:self];
[scrollView setDocumentView:view];
RELEASE(view);
[iView setMinSize:NSMakeSize (0, 0)];
[iView setMaxSize:NSMakeSize(1e7, 1e7)];
[iView setRichText:NO];
[iView setEditable:YES];
[iView setSelectable:YES];
[iView setVerticallyResizable:YES];
[iView setHorizontallyResizable:NO];
[iView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
[iView setBackgroundColor:[NSColor whiteColor]];
[[iView textContainer] setWidthTracksTextView:YES];
lm = [[NSLayoutManager alloc] init];
[storage addLayoutManager:lm];
RELEASE(lm);
tc = [[NSTextContainer alloc] initWithContainerSize:rect.size];
[lm addTextContainer:tc];
RELEASE(tc);
eView = [[PCEditorView alloc] initWithFrame:rect
textContainer:tc];
[eView setEditor:self];
[eView setMinSize: NSMakeSize (0, 0)];
[eView setMaxSize:NSMakeSize(1e7, 1e7)];
[eView setRichText:NO];
[eView setEditable:YES];
[eView setSelectable:YES];
[eView setVerticallyResizable:YES];
[eView setHorizontallyResizable:NO];
[eView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
[eView setBackgroundColor:[NSColor whiteColor]];
[[eView textContainer] setWidthTracksTextView:YES];
[scrollView setDocumentView:eView];
RELEASE(eView);
rect.size = NSMakeSize([scrollView contentSize].width,1e7);
[[view textContainer] setContainerSize:rect.size];
[[eView textContainer] setContainerSize:rect.size];
[scrollView setHasHorizontalScroller: YES];
[scrollView setHasVerticalScroller: YES];
@ -79,7 +117,7 @@ NSString *PCEditorDidResignKeyNotification=@"PCEditorDidResignKeyNotification";
[window setContentView:scrollView];
[window setDelegate:self];
[window makeFirstResponder:view];
[window makeFirstResponder:eView];
RELEASE(scrollView);
}
@ -92,22 +130,30 @@ NSString *PCEditorDidResignKeyNotification=@"PCEditorDidResignKeyNotification";
{
if((self = [super init]))
{
NSString *text = [NSString stringWithContentsOfFile:file];
NSString *t = [NSString stringWithContentsOfFile:file];
NSAttributedString *as = [[NSAttributedString alloc] initWithString:t];
// Should take that from preferences!
isEmbedded = NO;
isEdited = NO;
path = [file copy];
[self _initUI];
[window setTitle:file];
[view setText:text];
[storage setAttributedString:as];
RELEASE(as);
path = [file copy];
[iView setNeedsDisplay:YES];
[eView setNeedsDisplay:YES];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(textDidChange:)
name:NSTextDidChangeNotification
object:view];
object:eView];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(textDidChange:)
name:NSTextDidChangeNotification
object:iView];
}
return self;
}
@ -119,6 +165,9 @@ NSString *PCEditorDidResignKeyNotification=@"PCEditorDidResignKeyNotification";
RELEASE(window);
RELEASE(path);
RELEASE(iView);
RELEASE(storage);
[super dealloc];
}
@ -142,34 +191,32 @@ NSString *PCEditorDidResignKeyNotification=@"PCEditorDidResignKeyNotification";
return path;
}
- (void)setEmbedded:(BOOL)yn
- (void)setIsEdited:(BOOL)yn
{
isEmbedded = yn;
[window setDocumentEdited:yn];
isEdited = yn;
}
- (BOOL)isEmbedded
- (void)showInProjectEditor:(PCProjectEditor *)pe
{
return isEmbedded;
[pe setEditorView:iView];
}
- (void)show
{
if( isEmbedded == NO )
{
[window makeKeyAndOrderFront:self];
}
else
{
}
[window makeKeyAndOrderFront:self];
}
- (void)close
{
if( isEmbedded == NO && [window isDocumentEdited] )
if( isEdited )
{
BOOL ret;
[window makeKeyAndOrderFront:self];
if( [window isVisible] )
{
[window makeKeyAndOrderFront:self];
}
ret = NSRunAlertPanel(@"Edited File!",
@"Should the file be saved before closing?",
@ -189,9 +236,6 @@ NSString *PCEditorDidResignKeyNotification=@"PCEditorDidResignKeyNotification";
[window setDocumentEdited:NO];
}
else if( isEmbedded )
{
}
if( delegate && [delegate respondsToSelector:@selector(editorDidClose:)] )
{
@ -201,24 +245,25 @@ NSString *PCEditorDidResignKeyNotification=@"PCEditorDidResignKeyNotification";
- (BOOL)saveFile
{
if( isEmbedded == NO )
{
[window setDocumentEdited:NO];
}
[self setIsEdited:NO];
return [[view text] writeToFile:path atomically:YES];
// Operate on the text storage!
return [[storage string] writeToFile:path atomically:YES];
}
- (BOOL)revertFile
{
NSString *text = [NSString stringWithContentsOfFile:path];
NSAttributedString *as = [[NSAttributedString alloc] initWithString:text];
[view setText:text];
[self setIsEdited:NO];
if( isEmbedded == NO )
{
[window setDocumentEdited:NO];
}
// Operate on the text storage!
[storage setAttributedString:as];
RELEASE(as);
[iView setNeedsDisplay:YES];
[eView setNeedsDisplay:YES];
}
- (void)windowWillClose:(NSNotification *)aNotification
@ -247,7 +292,7 @@ NSString *PCEditorDidResignKeyNotification=@"PCEditorDidResignKeyNotification";
- (void)textDidChange:(NSNotification *)aNotification
{
[window setDocumentEdited:YES];
[self setIsEdited:YES];
}
@end

View file

@ -124,11 +124,7 @@
editor = [editorDict objectForKey:key];
[editor close];
if( [editor isEmbedded] == NO )
{
[[editor editorWindow] performClose:self];
}
[[editor editorWindow] performClose:self];
}
[editorDict removeAllObjects];
}
@ -156,7 +152,8 @@
editor = [editorDict objectForKey:key];
window = [editor editorWindow];
if( [window isKeyWindow] && [window isMainWindow] )
if( [window isKeyWindow] && [window isMainWindow] ||
[project isEditorActive] && [[project projectWindow] isKeyWindow])
{
return [editor saveFile];
}
@ -177,7 +174,8 @@
editor = [editorDict objectForKey:key];
window = [editor editorWindow];
if( [window isKeyWindow] && [window isMainWindow] )
if( [window isKeyWindow] && [window isMainWindow] ||
[project isEditorActive] && [[project projectWindow] isKeyWindow])
{
return [editor revertFile];
}

View file

@ -36,15 +36,24 @@
NSRange range;
NSArray *_keywords;
PCEditor *editor;
BOOL shouldHighlight;
}
- (id)initWithFrame:(NSRect)frameRect;
- (id)initWithFrame:(NSRect)frameRect textContainer:(NSTextContainer*)tc;
- (void)dealloc;
- (void)setEditor:(PCEditor *)anEditor;
- (void)setString:(NSString *)aString;
- (void)colourise:(id)sender;
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent;
- (void)setShouldHighlight:(BOOL)yn;
- (BOOL)shouldHighlight;
- (void)insertText:(id)aString;
- (void)highlightText;
- (void)highlightTextInRange:(NSRange)range;
- (void)colouriseKeyword:(NSString *)keyword;
- (void)colouriseKeywords:(NSArray *)keywords;

View file

@ -40,10 +40,11 @@ static NSColor *cStringColor = nil;
static NSFont *editorFont = nil;
static BOOL isInitialised = NO;
- (id)initWithFrame:(NSRect)frameRect
- (id)initWithFrame:(NSRect)frameRect textContainer:(NSTextContainer*)tc
{
if ((self = [super initWithFrame:frameRect]))
if ((self = [super initWithFrame:frameRect textContainer:tc]))
{
shouldHighlight = NO;
/*
* Should move that to initialize...
@ -96,29 +97,65 @@ static BOOL isInitialised = NO;
- (void)setString:(NSString *)aString
{
[scanner autorelease];
scanner = [[NSScanner alloc] initWithString:aString];
[scanner autorelease];
scanner = [[NSScanner alloc] initWithString:aString];
[super setString:aString];
[super setString:aString];
#ifdef COLOURISE
[self colourise:self];
if( shouldHighlight )
{
[self highlightText];
}
#endif //COLOURISE
}
- (void)colourise:(id)sender
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
{
return YES;
}
- (void)setShouldHighlight:(BOOL)yn
{
shouldHighlight = yn;
}
- (BOOL)shouldHighlight
{
return shouldHighlight;
}
- (void)insertText:(id)aString
{
NSRange txtRange = NSMakeRange(0, [[self textStorage] length]);
[super insertText:aString];
if( shouldHighlight )
{
[[self textStorage] invalidateAttributesInRange:txtRange];
[self highlightTextInRange:txtRange];
}
}
- (void)highlightText
{
NSRange txtRange = NSMakeRange(0, [[self textStorage] length]);
[self highlightTextInRange:txtRange];
}
- (void)highlightTextInRange:(NSRange)txtRange
{
NSRange aRange;
NSDictionary *aDict;
NSArray *keywords;
aRange = NSMakeRange(0,[_textStorage length]);
aDict = [NSDictionary dictionaryWithObjectsAndKeys:
editorFont, NSFontAttributeName,
@"UnknownCodeType", @"PCCodeTypeAttributeName",
nil];
[_textStorage beginEditing];
[_textStorage setAttributes:aDict range:aRange];
[_textStorage setAttributes:aDict range:txtRange];
// Scan the CodeType first...
@ -373,16 +410,9 @@ static BOOL isInitialised = NO;
if(([chars lossyCString][0] == 's') && (modifiers & NSCommandKeyMask))
{
[editor saveFile];
return;
}
// Only if not embedded - FIXME!
if( [[self window] isDocumentEdited] == NO )
{
[[self window] setDocumentEdited:YES];
}
[super keyDown:anEvent];
}

View file

@ -213,23 +213,20 @@ static PCFileManager *_mgr = nil;
NSArray *types = nil;
if (delegate &&
[delegate respondsToSelector:@selector(fileManagerWillAddFiles:)]) {
[delegate respondsToSelector:@selector(fileManagerWillAddFiles:)])
{
if (!(project = [delegate fileManagerWillAddFiles:self])) {
NSLog(@"No project to add files available...");
if (!(project = [delegate fileManagerWillAddFiles:self]))
{
return;
}
}
key = [project selectedRootCategory];
NSLog(@"Key: %@",key);
title = [[[project rootCategories] allKeysForObject:key] objectAtIndex:0];
title = [NSString stringWithFormat:@"Add to %@...",title];
NSLog(@"Title is %@ (Key %@)",title,key);
types = [project fileExtensionsForCategory:key];
openPanel = [NSOpenPanel openPanel];
@ -244,7 +241,8 @@ static PCFileManager *_mgr = nil;
NSEnumerator *enumerator;
NSString *file;
[[NSUserDefaults standardUserDefaults] setObject:[openPanel directory] forKey:@"LastOpenDirectory"];
[[NSUserDefaults standardUserDefaults] setObject:[openPanel directory]
forKey:@"LastOpenDirectory"];
enumerator = [[openPanel filenames] objectEnumerator];
while (file = [enumerator nextObject]) {

View file

@ -0,0 +1,40 @@
/*
* PCProject+ComponentHandling.h created by probert on 2002-02-10 09:51:00 +0000
*
* Project ProjectCenter
*
* Created with ProjectCenter - http://www.gnustep.org
*
* $Id$
*/
#ifndef _PCPROJECT_COMPONENTHANDLING_H_
#define _PCPROJECT_COMPONENTHANDLING_H_
#import <ProjectCenter/PCProject.h>
@interface PCProject (ComponentHandling)
- (void)topButtonsPressed:(id)sender;
- (void)showBuildView:(id)sender;
- (void)showRunView:(id)sender;
- (void)showEditorView:(id)sender;
- (void)showInspector:(id)sender;
- (id)updatedAttributeView;
- (id)updatedProjectView;
- (id)updatedFilesView;
- (void)showBuildTargetPanel:(id)sender;
- (void)setHost:(id)sender;
- (void)setArguments:(id)sender;
- (NSDictionary *)buildOptions;
- (BOOL)isEditorActive;
@end
#endif // _PCPROJECT_COMPONENTHANDLING_H_

View file

@ -0,0 +1,158 @@
/*
* PCProject+ComponentHandling.m created by probert on 2002-02-10 09:50:56 +0000
*
* Project ProjectCenter
*
* Created with ProjectCenter - http://www.gnustep.org
*
* $Id$
*/
#import "PCProject+ComponentHandling.h"
#import "PCProjectBuilder.h"
#import "PCProjectDebugger.h"
#import "PCProjectEditor.h"
#import "PCEditor.h"
@implementation PCProject (ComponentHandling)
- (void)topButtonsPressed:(id)sender
{
switch ([[sender selectedCell] tag])
{
case 0:
[self showBuildView:self];
break;
case 1:
[self showInspector:self];
break;
case 2:
[self showBuildTargetPanel:self];
break;
case 3:
if ([self isExecutable]) {
[self showRunView:self];
}
else {
NSRunAlertPanel(@"Attention!",
@"This project type is not executable!",
@"OK",nil,nil);
}
break;
case 4:
[self showEditorView:self];
break;
default:
break;
}
}
- (void)showBuildView:(id)sender
{
NSView *view = nil;
[[NSNotificationCenter defaultCenter] postNotificationName:PCEditorDidResignKeyNotification object:self];
editorIsActive = NO;
if (!projectBuilder) {
projectBuilder = [[PCProjectBuilder alloc] initWithProject:self];
}
view = [[projectBuilder componentView] retain];
[box setContentView:view];
[box sizeToFit];
[box display];
}
- (void)showRunView:(id)sender
{
NSView *view = nil;
[[NSNotificationCenter defaultCenter] postNotificationName:PCEditorDidResignKeyNotification object:self];
editorIsActive = NO;
if (!projectDebugger) {
projectDebugger = [[PCProjectDebugger alloc] initWithProject:self];
}
view = [[projectDebugger componentView] retain];
[box setContentView:view];
[box display];
}
- (void)showEditorView:(id)sender
{
NSView *view = nil;
[[NSNotificationCenter defaultCenter] postNotificationName:PCEditorDidBecomeKeyNotification object:self];
editorIsActive = YES;
if (!projectEditor) {
projectEditor = [[PCProjectEditor alloc] initWithProject:self];
}
view = [[projectEditor componentView] retain];
[box setContentView:view];
[box display];
}
- (void)showInspector:(id)sender
{
[projectManager showInspectorForProject:self];
}
- (id)updatedAttributeView
{
return projectAttributeInspectorView;
}
- (id)updatedProjectView
{
return projectProjectInspectorView;
}
- (id)updatedFilesView
{
return projectFileInspectorView;
}
- (void)showBuildTargetPanel:(id)sender
{
if (![buildTargetPanel isVisible])
{
[buildTargetPanel center];
}
[buildTargetPanel makeKeyAndOrderFront:self];
}
- (void)setHost:(id)sender
{
NSString *host = [buildTargetHostField stringValue];
[buildOptions setObject:host forKey:BUILD_HOST_KEY];
}
- (void)setArguments:(id)sender
{
NSString *args = [buildTargetArgsField stringValue];
[buildOptions setObject:args forKey:BUILD_ARGS_KEY];
}
- (NSDictionary *)buildOptions
{
return (NSDictionary *)buildOptions;
}
- (BOOL)isEditorActive
{
return editorIsActive;
}
@end

View file

@ -109,6 +109,7 @@ static NSString * const PCBuildTool = @"BUILDTOOL";
@class PCProjectBuilder;
@class PCProjectDebugger;
@class PCProjectEditor;
@class PCEditorController;
@interface PCProject : NSObject
@ -118,8 +119,9 @@ static NSString * const PCBuildTool = @"BUILDTOOL";
id projectManager;
id browserController;
PCProjectBuilder *projectBuilder;
PCProjectDebugger *projectDebugger;
PCProjectBuilder *projectBuilder;
PCProjectDebugger *projectDebugger;
PCProjectEditor *projectEditor;
PCEditorController *editorController;
NSBox *box;
@ -146,6 +148,8 @@ static NSString * const PCBuildTool = @"BUILDTOOL";
NSDictionary *rootCategories; // Needs to be initialised by subclasses!
NSMutableDictionary *buildOptions;
BOOL editorIsActive;
}
//=============================================================================
@ -272,26 +276,6 @@ static NSString * const PCBuildTool = @"BUILDTOOL";
@end
@interface PCProject (ProjectBuilding)
- (void)topButtonsPressed:(id)sender;
- (void)showBuildView:(id)sender;
- (void)showRunView:(id)sender;
- (void)showInspector:(id)sender;
- (id)updatedAttributeView;
- (id)updatedProjectView;
- (id)updatedFilesView;
- (void)showBuildTargetPanel:(id)sender;
- (void)setHost:(id)sender;
- (void)setArguments:(id)sender;
- (NSDictionary *)buildOptions;
@end
@interface PCProject (ProjectKeyPaths)
- (NSArray *)contentAtKeyPath:(NSString *)keyPath;
@ -302,6 +286,7 @@ static NSString * const PCBuildTool = @"BUILDTOOL";
@interface PCProject (ProjectWindowDelegate)
- (void)windowDidResignKey:(NSNotification *)aNotification;
- (void)windowDidBecomeKey:(NSNotification *)aNotification;
- (void)windowDidBecomeMain:(NSNotification *)aNotification;
- (void)windowWillClose:(NSNotification *)aNotification;

View file

@ -25,6 +25,8 @@
*/
#import "PCProject.h"
#import "PCProject+ComponentHandling.h"
#import "ProjectCenter.h"
#import "PCProjectBuilder.h"
#import "PCSplitView.h"
@ -88,49 +90,6 @@
[box setContentViewMargins: NSMakeSize(0.0,0.0)];
[box setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
/*
rect = [box frame];
rect.origin.x = -1;
rect.origin.y = -1;
rect.size.width += 2;
scrollView = [[NSScrollView alloc] initWithFrame:rect];
rect.origin.x = 0;
rect.origin.y = 0;
rect.size.height -= 24;
rect.size.width -= 4;
textView = [[NSTextView alloc] initWithFrame:rect];
[textView setText:@"This is a test"];
[textView setDrawsBackground:YES];
[textView setMinSize: NSMakeSize (0, 0)];
[textView setMaxSize:NSMakeSize(1e7, 1e7)];
[textView setRichText:NO];
[textView setEditable:YES];
[textView setSelectable:YES];
[textView setVerticallyResizable:YES];
[textView setHorizontallyResizable:NO];
[textView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
[textView setBackgroundColor:[NSColor whiteColor]];
[[textView textContainer] setWidthTracksTextView:YES];
[scrollView setDocumentView:textView];
[box addSubview:scrollView];
rect.size = NSMakeSize([scrollView contentSize].width,1e7);
[[textView textContainer] setContainerSize:rect.size];
[scrollView setHasHorizontalScroller: YES];
[scrollView setHasVerticalScroller: YES];
[scrollView setBorderType: NSBezelBorder];
[scrollView setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)];
RELEASE(textView);
RELEASE(scrollView);
*/
textField = [[NSTextField alloc] initWithFrame:NSMakeRect(16,200,500,21)];
[textField setAlignment: NSLeftTextAlignment];
[textField setBordered: NO];
@ -162,12 +121,12 @@
* Left button matrix
*/
rect = NSMakeRect(8,372,240,60);
rect = NSMakeRect(8,372,300,60);
matrix = [[NSMatrix alloc] initWithFrame: rect
mode: NSHighlightModeMatrix
prototype: buttonCell
numberOfRows: 1
numberOfColumns: 4];
numberOfColumns: 5];
[matrix sizeToCells];
[matrix setTarget:self];
[matrix setAction:@selector(topButtonsPressed:)];
@ -204,6 +163,13 @@
[button setImage:IMAGE(@"ProjectCentre_run.tiff")];
[button setButtonType:NSMomentaryPushButton];
button = [matrix cellAtRow:0 column:4];
[button setTag:4];
[button setImagePosition:NSImageAbove];
[button setTitle:@"Editor"];
[button setImage:IMAGE(@"ProjectCentre_files.tiff")];
[button setButtonType:NSMomentaryPushButton];
/*
* Build Options Panel
*
@ -443,6 +409,8 @@
{
if ((self = [super init]))
{
editorIsActive = NO;
buildOptions = [[NSMutableDictionary alloc] init];
[self _initUI];
@ -672,7 +640,17 @@
- (void)browserDidSelectFileNamed:(NSString *)fileName
{
NSString *p = [[self projectPath] stringByAppendingPathComponent:fileName];
PCEditor *e;
// Set the name in the inspector
[fileNameField setStringValue:fileName];
// Show the file in the internal editor!
e = [editorController editorForFile:p];
[e showInProjectEditor:projectEditor];
[self showEditorView:self];
[projectWindow makeFirstResponder:[projectEditor editorView]];
}
- (BOOL)doesAcceptFile:(NSString *)file forKey:(NSString *)type
@ -1116,117 +1094,8 @@
@end
@implementation PCProject (ProjectBuilding)
- (void)topButtonsPressed:(id)sender
{
switch ([[sender selectedCell] tag]) {
case 0:
[self showBuildView:self];
break;
case 1:
[self showInspector:self];
break;
case 2:
[self showBuildTargetPanel:self];
break;
case 3:
if ([self isExecutable]) {
[self showRunView:self];
}
else {
NSRunAlertPanel(@"Attention!",
@"This project type is not executable!",
@"OK",nil,nil);
}
break;
case 4:
case 5:
case 6:
NSRunAlertPanel(@"Help!",@"This feature is not yet implemented! Please contact me if you are interested in volunteering.",@"Of course!",nil,nil);
break;
default:
break;
}
}
- (void)showBuildView:(id)sender
{
NSView *view = nil;
if (!projectBuilder) {
projectBuilder = [[PCProjectBuilder alloc] initWithProject:self];
}
view = [[projectBuilder componentView] retain];
[box setContentView:view];
[box sizeToFit];
[box display];
}
- (void)showRunView:(id)sender
{
NSView *view = nil;
if (!projectDebugger) {
projectDebugger = [[PCProjectDebugger alloc] initWithProject:self];
}
view = [[projectDebugger componentView] retain];
[box setContentView:view];
[box display];
}
- (void)showInspector:(id)sender
{
[projectManager showInspectorForProject:self];
}
- (id)updatedAttributeView
{
return projectAttributeInspectorView;
}
- (id)updatedProjectView
{
return projectProjectInspectorView;
}
- (id)updatedFilesView
{
return projectFileInspectorView;
}
- (void)showBuildTargetPanel:(id)sender
{
if (![buildTargetPanel isVisible])
{
[buildTargetPanel center];
}
[buildTargetPanel makeKeyAndOrderFront:self];
}
- (void)setHost:(id)sender
{
NSString *host = [buildTargetHostField stringValue];
[buildOptions setObject:host forKey:BUILD_HOST_KEY];
}
- (void)setArguments:(id)sender
{
NSString *args = [buildTargetArgsField stringValue];
[buildOptions setObject:args forKey:BUILD_ARGS_KEY];
}
- (NSDictionary *)buildOptions
{
return (NSDictionary *)buildOptions;
}
@end
//=============================================================================
//=============================================================================
@implementation PCProject (ProjectKeyPaths)
@ -1274,8 +1143,21 @@
@implementation PCProject (ProjectWindowDelegate)
- (void)windowDidResignKey:(NSNotification *)aNotification
{
if( editorIsActive )
{
[[NSNotificationCenter defaultCenter] postNotificationName:PCEditorDidResignKeyNotification object:self];
}
}
- (void)windowDidBecomeKey:(NSNotification *)aNotification
{
if( editorIsActive )
{
[[NSNotificationCenter defaultCenter] postNotificationName:PCEditorDidBecomeKeyNotification object:self];
}
[projectManager setActiveProject:self];
}

View file

@ -28,10 +28,11 @@
#define _PCPROJECTBUILDER_H
#import <AppKit/AppKit.h>
#import <ProjectCenter/ProjectComponent.h>
@class PCProject;
@interface PCProjectBuilder : NSObject
@interface PCProjectBuilder : NSObject <ProjectComponent>
{
NSBox *componentView;
NSPopUpButton *popup;

View file

@ -26,6 +26,7 @@
#import "PCProjectBuilder.h"
#import "PCProject.h"
#import "PCProject+ComponentHandling.h"
#import "PCProjectManager.h"
#import <AppKit/AppKit.h>

View file

@ -25,10 +25,11 @@
*/
#import <AppKit/AppKit.h>
#import <ProjectCenter/ProjectComponent.h>
@class PCProject;
@interface PCProjectDebugger : NSObject
@interface PCProjectDebugger : NSObject <ProjectComponent>
{
NSBox *componentView;

40
PCLib/PCProjectEditor.h Normal file
View file

@ -0,0 +1,40 @@
/*
* PCProjectEditor.h created by probert on 2002-02-10 09:27:10 +0000
*
* Project ProjectCenter
*
* Created with ProjectCenter - http://www.gnustep.org
*
* $Id$
*/
#ifndef _PCPROJECTEDITOR_H_
#define _PCPROJECTEDITOR_H_
#import <Foundation/Foundation.h>
#import <ProjectCenter/ProjectComponent.h>
@class NSBox;
@class NSScrollView;
@class PCEditorView;
@interface PCProjectEditor : NSObject <ProjectComponent>
{
NSBox *componentView;
PCProject *currentProject;
PCEditorView *editor;
NSScrollView *scrollView;
}
- (id)initWithProject:(PCProject *)aProject;
- (void)dealloc;
- (NSView *)componentView;
- (void)setEditorView:(PCEditorView *)ev;
- (PCEditorView *)editorView;
@end
#endif // _PCPROJECTEDITOR_H_

125
PCLib/PCProjectEditor.m Normal file
View file

@ -0,0 +1,125 @@
/*
* PCProjectEditor.m created by probert on 2002-02-10 09:27:09 +0000
*
* Project ProjectCenter
*
* Created with ProjectCenter - http://www.gnustep.org
*
* $Id$
*/
#import "PCProjectEditor.h"
#import "PCEditorView.h"
@interface PCProjectEditor (CreateUI)
- (void)_createComponentView;
@end
@implementation PCProjectEditor (CreateUI)
- (void)_createComponentView
{
NSPopUpButton *methods;
NSRect frame;
NSTextView *etv;
componentView = [[NSBox alloc] initWithFrame:NSMakeRect(-1,-1,562,248)];
[componentView setTitlePosition:NSNoTitle];
[componentView setBorderType:NSNoBorder];
[componentView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
[componentView setContentViewMargins: NSMakeSize(0.0,0.0)];
frame = NSMakeRect(20,16,240,16);
methods = [[NSPopUpButton alloc] initWithFrame:frame];
[methods addItemWithTitle:@"No Method"];
[methods setPullsDown:YES];
[methods setTarget:self];
[methods setAction:@selector(pullDownSelected:)];
[componentView addSubview:methods];
RELEASE(methods);
frame = NSMakeRect (-1,32,562,40);
scrollView = [[NSScrollView alloc] initWithFrame:frame];
[scrollView setHasHorizontalScroller: YES];
[scrollView setHasVerticalScroller: YES];
[scrollView setBorderType: NSBezelBorder];
[scrollView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
// This is a placeholder!
frame = [[scrollView contentView] frame];
etv = [[NSTextView alloc] initWithFrame:frame];
[etv setMinSize: NSMakeSize (0, 0)];
[etv setMaxSize:NSMakeSize(1e7, 1e7)];
[etv setRichText:NO];
[etv setEditable:NO];
[etv setSelectable:YES];
[etv setVerticallyResizable:YES];
[etv setHorizontallyResizable:NO];
[etv setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
[[etv textContainer] setWidthTracksTextView:YES];
[scrollView setDocumentView:etv];
RELEASE(etv);
frame.size = NSMakeSize([scrollView contentSize].width,1e7);
[[etv textContainer] setContainerSize:frame.size];
[componentView addSubview:scrollView];
RELEASE(scrollView);
[componentView sizeToFit];
}
@end
@implementation PCProjectEditor
- (id)initWithProject:(PCProject *)aProject
{
NSAssert(aProject,@"No project specified!");
if((self = [super init]))
{
currentProject = aProject;
}
return self;
}
- (void)dealloc
{
RELEASE(componentView);
[super dealloc];
}
- (NSView *)componentView
{
if (!componentView)
{
[self _createComponentView];
}
return componentView;
}
- (void)setEditorView:(PCEditorView *)ev
{
NSRect frame;
editor = ev;
frame = [[scrollView contentView] frame];
[scrollView setDocumentView:editor];
[editor setNeedsDisplay:YES];
frame.size = NSMakeSize([scrollView contentSize].width,1e7);
[[editor textContainer] setContainerSize:frame.size];
}
- (PCEditorView *)editorView
{
return editor;
}
@end

View file

@ -30,9 +30,11 @@
#import <ProjectCenter/PCBundleLoader.h>
#import <ProjectCenter/PCDataSource.h>
#import <ProjectCenter/PCDefines.h>
#import <ProjectCenter/PCProjectEditor.h>
#import <ProjectCenter/PCProjectManager.h>
#import <ProjectCenter/PCServer.h>
#import <ProjectCenter/PCProject.h>
#import <ProjectCenter/PCProject+ComponentHandling.h>
#import <ProjectCenter/PCProjectBuilder.h>
#import <ProjectCenter/PCProjectDebugger.h>
#import <ProjectCenter/PCFileManager.h>
@ -41,6 +43,7 @@
#import <ProjectCenter/ProjectEditor.h>
#import <ProjectCenter/ProjectType.h>
#import <ProjectCenter/Server.h>
#import <ProjectCenter/ProjectComponent.h>
#import <ProjectCenter/PreferenceController.h>
#import <ProjectCenter/ProjectBuilder.h>
#import <ProjectCenter/FileCreator.h>

View file

@ -15,7 +15,9 @@
PCSplitView.m,
PCEditor.m,
PCEditorController.m,
PCTextFinder.m
PCTextFinder.m,
PCProjectEditor.m,
PCProject+ComponentHandling.m
);
COMPILEROPTIONS = "";
CREATION_DATE = "";
@ -47,7 +49,10 @@
PCEditor.h,
PCEditorController.h,
PCDefines.h,
PCTextFinder.h
PCTextFinder.h,
PCProjectEditor.h,
ProjectComponent.h,
PCProject+ComponentHandling.h
);
INSTALLDIR = "$(GNUSTEP_SYSTEM_ROOT)";
LANGUAGE = English;

20
PCLib/ProjectComponent.h Normal file
View file

@ -0,0 +1,20 @@
/*
* ProjectComponent.h created by probert on 2002-02-10 09:29:07 +0000
*
* Project ProjectCenter
*
* Created with ProjectCenter - http://www.gnustep.org
*
* $Id$
*/
@class PCProject;
@class NSView;
@protocol ProjectComponent <NSObject>
- (id)initWithProject:(PCProject *)aProject;
- (NSView *)componentView;
@end

View file

@ -29,8 +29,9 @@
#import "PCPrefController.h"
#import "PCInfoController.h"
#import <ProjectCenter/PCProjectManager.h>
#import <ProjectCenter/PCTextFinder.h>
#import "PCProject+ComponentHandling.h"
#import "PCProjectManager.h"
#import "PCTextFinder.h"
@implementation PCAppController (MenuHandling)