Start merging branches

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@19495 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Sergii Stoian 2004-06-11 13:43:02 +00:00
parent d288662f70
commit 6f7a22551b
313 changed files with 22935 additions and 15556 deletions

3
.dist-ignore Normal file
View file

@ -0,0 +1,3 @@
.gwdir
*.swp
*~

View file

@ -1,8 +0,0 @@
Philippe C.D. Robert
Adam Fedor
Pierre-Yves Rivaille
Nicola Perot
Richard Frith-Macdonald
David Ayers
Serg Stoyan

59
Documentation/ANNOUNCE Normal file
View file

@ -0,0 +1,59 @@
Announcement
************
This is version 0.3.5 of ProjectCenter.
What is ProjectCenter?
======================
ProjectCenter is a clone of the NEXTSTEP ProjectBuilder application for
GNUstep.
ProjectCenter is covered under the GNU Public License. This means if you
make changes to these programs, you cannot charge a fee, other than
distribution fees, for others to use the program. You should read the
COPYING file for more information.
Noteworthy changes in version `0.3.5'.
======================================
Many features have been polished and stabilised, see ChangeLog for the
complete list of changes.
How can I get support for this software?
========================================
You may wish to use the GNUstep discussion mailing list for general
questions and discussion. Look at the GNUstep Web Pages for more
information regarding GNUstep resources <http://www.gnustep.org/>
Where can you get it? How can you compile it?
==============================================
You can download sources and rpms (for some machines) from
ftp://ftp.gnustep.org/pub/gnustep/dev-apps/.
Where do I send bug reports?
============================
Bug reports can be sent to <bug-gnustep@gnu.org>.
Obtaining GNU Software
======================
Check out the GNU web site. (`http://www.gnu.org/')
Check out the GNUstep web site. (`http://www.gnustep.org/')
Most GNU software is packed using the GNU `gzip' compression program.
Source code is available on most sites distributing GNU software.
For information on how to order GNU software on tape, floppy or
cd-rom, or printed GNU manuals, check the file etc/ORDERS in the GNU
Emacs distribution or in GNUinfo/ORDERS on prep, or e-mail a request to:
<gnu@gnu.org>
By ordering your GNU software from the FSF, you help us continue to
develop more free software. Media revenues are our primary source of
support. Donations to FSF are deductible on US tax returns.

8
Documentation/AUTHORS Normal file
View file

@ -0,0 +1,8 @@
Philippe C.D. Robert <probert@siggraph.org>
Serg Stoyan <stoyan255@ukr.net>
David Ayers <d.ayers@inode.at>
Richard Frith-Macdonald <rfm@gnu.org>
Nicola Pero <n.pero@mi.flashnet.it>
Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
Adam Fedor <fedor@gnu.org>

87
Documentation/ChangeLog Normal file
View file

@ -0,0 +1,87 @@
2004-06-09 Serg Stoyan <stoyan255@ukr.net>
* Library/PCProjectBrowser.[hm]:
(pathOfSelectedFile): renamed to pathToSelectedFile.
(nameOfSelectedCategory): implemented. Use it insetead PCProject's
-categoryForCategoryPath.
(pathToSelectedCategory): implemented.
(setPathForFile:category:): removed.
(reloadLastColumn): implemented.
* Modules/ApplicationProject/PCAppProject.m:
(renameFile:toFile:): remove calling of PCProjectBrowser's
setPathForFile:category.
* Modules/RenaissanceProject/ PCRenaissanceProject.m:
(renameFile:toFile:): ditto.
* Library/PCLoadedFilesPanel.m:
* Library/PCBuildPanel.m:
* Library/PCLaunchPanel.m:
(activeProjectDidChange:): return if root project wasn't changed.
* Library/PCProject.m:
(setProjectmanager:): don't set project components for subproject.
2004-06-02 Serg Stoyan <stoyan255@ukr.net>
* Library/PCProjectManager (openProjectAt:): get project name from
PC.project file instead of directory name. So project name and
directory name may differ.
* Library/PCProjectLauncher.m (debug:): Debug application using
full path instead of "~/Application".
* PCMenuController.m: disable "Tear-Off Editor Size" fields editing
if Project Editor is not tear-off or Editor is not "ProjectCenter".
Check only first arg of Editor value.
2004-06-01 Serg Stoyan <stoyan255@ukr.net>
* Finished on-the-fly applying "Tear-Off Panels" preferences.
* Implemented remembering windows and panels visibility on project
opening.
* Various PCProject fixes.
* Remove PC.project.backup if preference "Keep Project Backup File"
is not set.
2004-05-27 Serg Stoyan <stoyan255@ukr.net>
* Finished support of external editors.
2004-05-10 Serg Stoyan <stoyan@on.com.ua>
* Preferences interface created using GORM.
* Resources/Prefernces.gorm: added.
* PCPrefController+UInterface.[hm]: removed.
2004-05-08 Serg Stoyan <stoyan@on.com.ua>
* Start new ChangeLog. Old ChangeLog resides in
Documentation/ChangeLog-1 new in Documentation/ChangeLog.
* Summary of changes:
- massive overall refactoring and cleanup. Directory layout
of PC changed;
- ProjectWindow: implemented toolbar(hide/show); menu entry
implemented;
- ProjectInspector: PC*Project's parts moved into PC*Projects;
more or less finished;
- ProjectBuilder: switch from NSThread to NSTask method of
executing tasks; "Build", "Stop Build", "Clean" menu entries
implemented;
- ProjectLauncher: ditto; finished all related menu entries;
- LoadedFiles: Fully implemented;
- LogController: implemented; made use it;
- initial subprojects support added;
- more stability around the whole ProjectCenter;
- GORMified parts of PC now is: PC main menu, ProjectInspector,
"File->New in Project" panel, "Project-> New Subproject"
panel.
- "File->Rename" implemented;
- ProjectCenter library now framework.

2092
Documentation/ChangeLog-1 Normal file

File diff suppressed because it is too large Load diff

28
Documentation/README Normal file
View file

@ -0,0 +1,28 @@
ProjectCenter
=============
This is ProjectCenter, the GNUstep IDE which is part of the GNUstep
project and is copyrighted by the Free Softare Foundation. ProjectCenter
is released under the GPL - see 'COPYING' for the details.
Further information can be found on the GNUstep site at www.gnustep.org
on the ProjectCenter page
http://www.gnustep.org/developers/ProjectCenter.html
For the installation instructions read the INSTALL file.
For a list of upcoming and/or planned features read the TODO file.
For a list of changes in released versions read the ANNOUNCE file.
The main author of ProjectCenter is Philippe C.D. Robert, but others
have contributed a lot to the current state of the project:
Code - Pierre-Yves Rivaille
Nicola Perot
Richard Frith-Macdonald
Adam Fedor
Serg Stoyan
UI - Many of the icons have been created by Andrew Lindsay

67
Documentation/SCHEME Normal file
View file

@ -0,0 +1,67 @@
+- PCProjectInspector
|
+- PCLoadedFilesPanel
|
+- PCBuildPanel
|
+- PCLaunchPanel
|
+- [SI]PCFindPanel
PCAppController-\ |
| ----- PCProjectManager
PCMenuController/ | ||
| PCProject <PCAppProject, PCBundleProject>
| |
| +- PCProjectWindow
| |
| +- PCProjectBrowser
| |
| +- PCProjectLoadedFiles
| |
| +- PCProjectBuilder
| |
| +- PCProjectLauncher
| |
| +- [SI]PCProjectFinder
| |
| +- PCProjectEditor
| ||
| PCEditor
| |
| +- PCEditorView
|
PCTextFinder
|
PCFileManager
|
+- PCFileCreator
------------------------------
Other (controls, tools, etc.):
------------------------------
PCButton
PCSplitView
PCOutputView (Should be implemented. Used by e.g. Project Builder)
PCBundleLoader (Used in ProjectCenter application)
PCMakefileFactory (Used in PC*Project bundles)
PCServer (don't used)
----------
THOUGHTS:
----------
- test Projects and Files operations (Project and File menu entries);
- GORMify Prefernces;
- make PC prefernces changes applying immediately after changing;
- finish Preferences;
- remember ProjectWindow, BuildPanel, LaunchPanel, LoadedFilesPanel
geometry and visibility on per project basis;
- remember splitviews geometry on per project basis;
- try to incorporate CodeEditor approach
- implement PCProjectFinder and PCFindPanel GUI;
- "Edit" menu should be completely provided by Editor part;
- "Add Files" panel should provide selection of type and "Choose Folders"
and "Add Class", "Add Header" and so on checkbox;
- "New File in Project..." panel should provide "Create Header",
"Create Class" and so on checkbox.

62
Documentation/TODO Normal file
View file

@ -0,0 +1,62 @@
TODO
****
This is the GNUstep ProjectCenter TODO list. "+" means that this task
is done. Feel free to propose changes to this list or make suggestions!
ProjectCenter 0.4 Owner
----------------- ------
+ Review and cleanup of PC project bundles/templates stoyan
+ Finish Project Inspector stoyan
+ Inspector UI using Gorm stoyan
+ File creation (File->New in project) cleanup and finishing stoyan
- Initial suprojects support stoyan
+ Finish support of external editors stoyan
+ Preferences enhancements and UI using Gorm stoyan
+ Remember project windows and panels in PC.project stoyan
ProjectCenter 0.5
-----------------
- Redesign Info panel stoyan
- ProjectBuilder enhancements (warnings,errors,options etc.) stoyan
- ProjectLauncher enhancements (debug) stoyan
- Finish ProjectWindow and its contents (Browser, FileIcon) stoyan
- Editor enhancements robert
ProjectCenter 0.6
-----------------
- More options for file creation ???
- ProjectCenter localization robert
- Localization support for GUI based projects robert
- Direct code documentation (using autogsdoc) ???
- Better integration with other tools
(Gorm, CodeEditor, EasyDiff) ???
ProjectCenter 0.7
-----------------
- Initial user documentation ???
- Initial support for integrated debugging ???
- Optimised support for integrated debugging ???
- More project customisation possibilities ???
- CVS integration ???
ProjectCenter 0.8
-----------------
- An initial project wide find feature ???
ProjectCenter 0.9
-----------------
- An initial class browser/documentation feature ???
ProjectCenter 1.0
-----------------
Version 1.0 is aimed at stabilising and optimising existing
features. There will not be any new features since 0.9.

View file

@ -1,120 +1,119 @@
#
# GNUmakefile - Generated by ProjectCenter
# Written by Philippe C.D. Robert <probert@siggraph.org>
#
# NOTE: Do NOT change this file -- ProjectCenter maintains it!
#
# Put all of your customisations in GNUmakefile.preamble and
# GNUmakefile.postamble
# GNUmakefile
#
include $(GNUSTEP_MAKEFILES)/common.make
GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_SYSTEM_ROOT)
#
# Main application
#
PACKAGE_NAME = ProjectCenter
APP_NAME = ProjectCenter
ProjectCenter_APPLICATION_ICON = Images/ProjectCenter.tiff
VERSION = 0.4
COMPRESSION = gzip
#
# Subprojects
#
SUBPROJECTS = \
PCLib \
PCAppProj \
PCGormProj \
PCBundleProj \
PCToolProj \
PCLibProj \
PCBaseFileTypes \
PCRenaissanceProj
#
# Main application
#
PACKAGE_NAME = ProjectCenter
APP_NAME = ProjectCenter
ProjectCenter_APPLICATION_ICON = Images/ProjectCenter.tiff
#
# Additional libraries
#
ADDITIONAL_GUI_LIBS += -lProjectCenter
SUBPROJECTS = \
Library \
Modules \
#
# Resource files
#
ProjectCenter_RESOURCE_FILES = \
Resources/ProjectCenter.gorm \
Resources/LogPanel.gorm \
Resources/Preferences.gorm \
ProjectCenterInfo.plist \
Images/ButtonTile.tiff \
Images/FileIcon_.c.tiff \
Images/FileIcon_.h.tiff \
Images/FileIcon_.m.tiff \
Images/FileIcon_rtf.tiff \
Images/ProjectCenter.tiff \
Images/ButtonTile.tiff \
Images/FileC.tiff \
Images/FileCH.tiff \
Images/FileH.tiff \
Images/FileHH.tiff \
Images/FileM.tiff \
Images/FileMH.tiff \
Images/FileRTF.tiff \
Images/FileProject.tiff \
Images/Build.tiff \
Images/Clean.tiff \
Images/Debug.tiff \
Images/Files.tiff \
Images/Find.tiff \
Images/Inspector.tiff \
Images/Install.tiff \
Images/MultiFiles.tiff \
Images/Options.tiff \
Images/Run.tiff \
Images/Stop.tiff \
Images/Editor.tiff \
Images/ProjectCenter_add.tiff \
Images/ProjectCenter_build.tiff \
Images/ProjectCenter_clean.tiff \
Images/ProjectCenter_cvs.tiff \
Images/ProjectCenter_debug.tiff \
Images/ProjectCenter_dist.tiff \
Images/ProjectCenter_documentation.tiff \
Images/ProjectCenter_files.tiff \
Images/ProjectCenter_find.tiff \
Images/ProjectCenter_install.tiff \
Images/ProjectCenter_make.tiff \
Images/ProjectCenter_prefs.tiff \
Images/ProjectCenter_profile.tiff \
Images/ProjectCenter_rpm.tiff \
Images/ProjectCenter_run.tiff \
Images/ProjectCenter_settings.tiff \
Images/ProjectCenter_uml.tiff \
Images/Stop.tiff \
PCAppProj/PCAppProj.bundle \
PCGormProj/PCGormProj.bundle \
PCBundleProj/PCBundleProj.bundle \
PCToolProj/PCToolProj.bundle \
PCLibProj/PCLibProj.bundle \
PCBaseFileTypes/PCBaseFileTypes.bundle \
PCRenaissanceProj/PCRenaissanceProj.bundle
Images/classSuitcase.tiff \
Images/classSuitcaseH.tiff \
Images/genericSuitcase.tiff \
Images/genericSuitcaseH.tiff \
Images/headerSuitcase.tiff \
Images/headerSuitcaseH.tiff \
Images/helpSuitcase.tiff \
Images/helpSuitcaseH.tiff \
Images/iconSuitcase.tiff \
Images/iconSuitcaseH.tiff \
Images/librarySuitcase.tiff \
Images/librarySuitcaseH.tiff \
Images/nibSuitcase.tiff \
Images/nibSuitcaseH.tiff \
Images/otherSuitcase.tiff \
Images/otherSuitcaseH.tiff \
Images/projectSuitcase.tiff \
Images/projectSuitcaseH.tiff \
Images/soundSuitcase.tiff \
Images/soundSuitcaseH.tiff \
Images/subprojectSuitcase.tiff \
Images/subprojectSuitcaseH.tiff \
Modules/ApplicationProject/ApplicationProject.bundle \
Modules/BundleProject/BundleProject.bundle \
Modules/LibraryProject/LibraryProject.bundle \
Modules/RenaissanceProject/RenaissanceProject.bundle \
Modules/ToolProject/ToolProject.bundle
#
# Header files
#
ProjectCenter_HEADERS = \
PCAppController.h \
PCFindController.h \
PCInfoController.h \
PCLogController.h \
PCMenuController.h \
PCPrefController.h \
PCPrefController+UInterface.h
PCPrefController.h
#
# Class files
#
ProjectCenter_OBJC_FILES = \
PCAppController.m \
PCFindController.m \
PCInfoController.m \
PCLogController.m \
PCMenuController.m \
PCPrefController.m \
PCPrefController+UInterface.m \
ProjectCenter_main.m
#
# C files
#
ProjectCenter_C_FILES =
-include GNUmakefile.preamble
include $(GNUSTEP_MAKEFILES)/aggregate.make
include $(GNUSTEP_MAKEFILES)/application.make
-include GNUmakefile.postamble

View file

@ -24,15 +24,6 @@
# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Makefile.preamble
#
# Project specific makefile variables, and additional
#
# Do not put any Makefile rules in this file, instead they should
# be put into Makefile.postamble.
#
#
# Flags dealing with compiling and linking
#
@ -41,19 +32,20 @@
ADDITIONAL_CPPFLAGS += -Wall
# Additional flags to pass to the Objective-C compiler
ADDITIONAL_OBJCFLAGS += -Wall
ADDITIONAL_OBJCFLAGS += -Wall -Werror
# Additional flags to pass to the C compiler
ADDITIONAL_CFLAGS += -Wall
# Additional include directories the compiler should search
ADDITIONAL_INCLUDE_DIRS += -I./PCLib
ADDITIONAL_INCLUDE_DIRS += -I./Library
# Additional LDFLAGS to pass to the linker
#ADDITIONAL_LDFLAGS +=
ADDITIONAL_LDFLAGS += -lProjectCenter
# Additional library directories the linker should search
ADDITIONAL_LIB_DIRS += -L./PCLib/$(GNUSTEP_OBJ_DIR)
#ADDITIONAL_LIB_DIRS += -L./Library/$(GNUSTEP_OBJ_DIR)
ADDITIONAL_LIB_DIRS += -L./Library/ProjectCenter.framework/Versions/Current
ADDITIONAL_TOOL_LIBS +=

Binary file not shown.

BIN
Images/Editor.tiff Normal file

Binary file not shown.

BIN
Images/FileC.tiff Normal file

Binary file not shown.

BIN
Images/FileCH.tiff Normal file

Binary file not shown.

BIN
Images/FileH.tiff Normal file

Binary file not shown.

BIN
Images/FileHH.tiff Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Images/FileM.tiff Normal file

Binary file not shown.

BIN
Images/FileMH.tiff Normal file

Binary file not shown.

BIN
Images/FileProject.tiff Normal file

Binary file not shown.

BIN
Images/Options.tiff Normal file

Binary file not shown.

Binary file not shown.

BIN
Images/classSuitcase.tiff Normal file

Binary file not shown.

BIN
Images/classSuitcaseH.tiff Normal file

Binary file not shown.

BIN
Images/genericSuitcase.tiff Normal file

Binary file not shown.

Binary file not shown.

BIN
Images/headerSuitcase.tiff Normal file

Binary file not shown.

BIN
Images/headerSuitcaseH.tiff Normal file

Binary file not shown.

BIN
Images/helpSuitcase.tiff Normal file

Binary file not shown.

BIN
Images/helpSuitcaseH.tiff Normal file

Binary file not shown.

BIN
Images/iconSuitcase.tiff Normal file

Binary file not shown.

BIN
Images/iconSuitcaseH.tiff Normal file

Binary file not shown.

BIN
Images/librarySuitcase.tiff Normal file

Binary file not shown.

Binary file not shown.

BIN
Images/nibSuitcase.tiff Normal file

Binary file not shown.

BIN
Images/nibSuitcaseH.tiff Normal file

Binary file not shown.

BIN
Images/otherSuitcase.tiff Normal file

Binary file not shown.

BIN
Images/otherSuitcaseH.tiff Normal file

Binary file not shown.

BIN
Images/projectSuitcase.tiff Normal file

Binary file not shown.

Binary file not shown.

BIN
Images/soundSuitcase.tiff Normal file

Binary file not shown.

BIN
Images/soundSuitcaseH.tiff Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

128
Library/GNUmakefile Normal file
View file

@ -0,0 +1,128 @@
#
# GNUmakefile - Generated by ProjectCenter
#
include $(GNUSTEP_MAKEFILES)/common.make
GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_SYSTEM_ROOT)
#
# Library
#
#LIBRARY_VAR = PROJECTCENTER
#PACKAGE_NAME = ProjectCenter
#VERSION = 0.4.0
FRAMEWORK_NAME = ProjectCenter
ProjectCenter_CURRENT_VERSION_NAME = 0.4.0
ProjectCenter_DEPLOY_WITH_CURRENT_VERSION = yes
#libProjectCenter_HEADER_FILES_INSTALL_DIR = ProjectCenter
#HEADERS_INSTALL = $(libProjectCenter_HEADER_FILES)
ProjectCenter_LIBRARIES_DEPEND_UPON += -lgnustep-gui
#
# Subprojects
#
#SUBPROJECTS = Resources
#
# Header files
#
ProjectCenter_HEADER_FILES = \
PCBundleLoader.h \
PCFileManager.h \
PCFileCreator.h \
PCServer.h \
PCMakefileFactory.h \
PCSplitView.h \
PCButton.h \
\
PCProjectManager.h \
PCBuildPanel.h \
PCLaunchPanel.h \
PCLoadedFilesPanel.h \
PCProject.h \
PCProjectWindow.h \
PCProjectInspector.h \
PCProjectBuilder.h \
PCProjectLauncher.h \
PCProjectEditor.h \
\
PCProjectBrowser.h \
PCProjectLoadedFiles.h \
\
PCEditor.h \
PCEditorView.h \
PCEditorView+Highlighting.h \
PCTextFinder.h \
PCTextFinder+UInterface.h \
\
PCDefines.h \
PreferenceController.h \
ProjectBuilder.h \
ProjectCenter.h \
ProjectEditor.h \
ProjectType.h \
Server.h \
ProjectComponent.h
#
# Class files
#
ProjectCenter_OBJC_FILES = \
PCBundleLoader.m \
PCFileManager.m \
PCFileCreator.m \
PCServer.m \
PCMakefileFactory.m \
PCSplitView.m \
PCButton.m \
\
PCProjectManager.m \
PCBuildPanel.m \
PCLaunchPanel.m \
PCLoadedFilesPanel.m \
PCProject.m \
PCProjectWindow.m \
PCProjectInspector.m \
PCProjectBuilder.m \
PCProjectLauncher.m \
PCProjectEditor.m \
\
PCProjectBrowser.m \
PCProjectLoadedFiles.m \
\
PCEditor.m \
PCEditorView.m \
PCEditorView+Highlighting.m \
PCTextFinder.m \
PCTextFinder+UInterface.m
#
# Resources
#
ProjectCenter_RESOURCE_FILES = \
Resources/NewSubproject.gorm \
Resources/NewFile.gorm \
Resources/ProjectInspector.gorm \
Resources/BuildAttributes.gorm \
Resources/ProjectDescription.gorm \
Resources/FileAttributes.gorm \
Resources/cfile.template \
Resources/cheader.template \
Resources/class.template \
Resources/gsmarkup.template \
Resources/header.template \
Resources/postamble.template \
Resources/protocol.template
-include GNUmakefile.preamble
include $(GNUSTEP_MAKEFILES)/framework.make
include $(GNUSTEP_MAKEFILES)/aggregate.make
-include GNUmakefile.postamble

View file

@ -0,0 +1,35 @@
#
# GNUmakefile.postamble
#
# Copyright (C) 2001 Free Software Foundation, Inc.
#
# Author: Philippe C.D. Robert <probert@siggraph.org>
#
# This file is part of GNUstep
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; see the file COPYING.LIB.
# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
before-all::
rm -f ProjectCenter
$(LN_S) . ProjectCenter
after-clean::
rm -f ProjectCenter
after-uninstall::
rm -rf $(GNUSTEP_SYSTEM_ROOT)/Library/Headers/ProjectCenter
rm -rf $(GNUSTEP_SYSTEM_ROOT)/Library/Libraries/Resources/ProjectCenter

View file

@ -0,0 +1,71 @@
# GNUmakefile.preamble
#
# Copyright (C) 2001 Free Software Foundation, Inc.
#
# Author: Philippe C.D. Robert <probert@siggraph.org>
#
# This file is part of GNUstep
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# If you are interested in a warranty or support for this source code,
# contact Scott Christley at scottc@net-community.com
#
# You should have received a copy of the GNU Library General Public
# License along with this library; see the file COPYING.LIB.
# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# Makefile.preamble
#
# Project specific makefile variables, and additional
#
# Do not put any Makefile rules in this file, instead they should
# be put into Makefile.postamble.
#
#
# Flags dealing with compiling and linking
#
# Additional flags to pass to the preprocessor
ADDITIONAL_CPPFLAGS += -Wall -Werror
# Additional flags to pass to the Objective-C compiler
ADDITIONAL_OBJCFLAGS += -Wall -Werror
# Additional flags to pass to the C compiler
ADDITIONAL_CFLAGS += -Wall -Werror
# Additional include directories the compiler should search
ADDITIONAL_INCLUDE_DIRS += -I../
# Additional LDFLAGS to pass to the linker
#ADDITIONAL_LDFLAGS +=
# Additional library directories the linker should search
ADDITIONAL_LIB_DIRS += -L../ProjectCenter/$(GNUSTEP_OBJ_DIR)
ADDITIONAL_TOOL_LIBS +=
#
# Flags dealing with installing and uninstalling
#
# Additional directories to be created during installation
ADDITIONAL_INSTALL_DIRS +=
#
# Local configuration
#

View file

@ -3,7 +3,7 @@
Copyright (C) 2003 Free Software Foundation
Author: Philippe C.D. Robert <probert@siggraph.org>
Author: Serg Stoyan <stoyan@on.com.ua>
This file is part of GNUstep.
@ -20,20 +20,25 @@
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$Id$
*/
#ifndef __PCPREFCONTROLLER_UINTERFACE_H
#define __PCPREFCONTROLLER_UINTERFACE_H
#ifndef _PCBuildPanel_h
#define _PCBuildPanel_h
#include "PCPrefController.h"
#include <AppKit/AppKit.h>
@interface PCPrefController (UInterface)
@class PCProjectManager;
- (void)_initUI;
@interface PCBuildPanel : NSPanel
{
PCProjectManager *projectManager;
PCProject *currentProject;
NSBox *contentBox;
NSBox *emptyBox;
}
- (id)initWithProjectManager:(PCProjectManager *)aManager;
@end
#endif

150
Library/PCBuildPanel.m Normal file
View file

@ -0,0 +1,150 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2003 Free Software Foundation
Author: Serg Stoyan <stoyan@on.com.ua>
This file is part of GNUstep.
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#include "PCProjectManager.h"
#include "PCProject.h"
#include "PCProjectBuilder.h"
#include "PCBuildPanel.h"
#include "PCLogController.h"
@implementation PCBuildPanel
- (id)initWithProjectManager:(PCProjectManager *)aManager
{
PCProjectBuilder *projectBuilder = nil;
PCProject *activeProject = nil;
projectManager = aManager;
activeProject = [projectManager rootActiveProject];
projectBuilder = [activeProject projectBuilder];
self = [super initWithContentRect: NSMakeRect (0, 300, 480, 322)
styleMask: (NSTitledWindowMask
| NSClosableWindowMask
| NSResizableWindowMask)
backing: NSBackingStoreRetained
defer: YES];
[self setMinSize: NSMakeSize(440, 222)];
[self setFrameAutosaveName: @"ProjectBuilder"];
[self setReleasedWhenClosed: NO];
[self setHidesOnDeactivate: NO];
[self setTitle: [NSString stringWithFormat:
@"%@ - Project Build", [activeProject projectName]]];
// Panel's content view
contentBox = [[NSBox alloc] init];
[contentBox setContentViewMargins:NSMakeSize(8.0, 0.0)];
[contentBox setTitlePosition:NSNoTitle];
[contentBox setBorderType:NSNoBorder];
[super setContentView:contentBox];
// Empty content view of contentBox
emptyBox = [[NSBox alloc] init];
[emptyBox setContentViewMargins:NSMakeSize(0.0, 0.0)];
[emptyBox setTitlePosition:NSNoTitle];
[emptyBox setBorderType:NSLineBorder];
[contentBox setContentView:emptyBox];
// Track project switching
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(activeProjectDidChange:)
name:PCActiveProjectDidChangeNotification
object:nil];
if (![self setFrameUsingName: @"ProjectBuilder"])
{
[self center];
}
return self;
}
- (void)dealloc
{
NSLog(@"PCBuildPanel: dealloc");
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
- (void)orderFront:(id)sender
{
PCProject *activeProject = [projectManager rootActiveProject];
NSView *builderView = [[activeProject projectBuilder] componentView];
if (!([contentBox contentView] == builderView))
{
[contentBox setContentView:builderView];
[contentBox display];
}
PCLogInfo(self, @"orderFront: %@ -> %@",
builderView, [builderView superview]);
[super orderFront:self];
}
- (void)close
{
PCLogInfo(self, @"close: %@", [contentBox contentView]);
[contentBox setContentView:emptyBox];
PCLogInfo(self, @"close: %@", [contentBox contentView]);
[super close];
}
- (void)activeProjectDidChange:(NSNotification *)aNotif
{
PCProject *rootProject = [projectManager rootActiveProject];
if (rootProject == currentProject)
{
return;
}
currentProject = rootProject;
PCLogInfo(self, @"activeProjectDidChange to: %@",
[rootProject projectName]);
if (!rootProject)
{
[contentBox setContentView:emptyBox];
}
else
{
[self setTitle: [NSString stringWithFormat:
@"%@ - Project Build", [rootProject projectName]]];
[contentBox
setContentView:[[rootProject projectBuilder] componentView]];
}
}
@end

View file

@ -1,9 +1,9 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2001 Free Software Foundation
Copyright (C) 2000-2002 Free Software Foundation
Author: Philippe C.D. Robert <phr@3dkit.org>
Author: Philippe C.D. Robert <probert@siggraph.org>
This file is part of GNUstep.
@ -22,29 +22,48 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#ifndef _PCGORMPROJ_H
#define _PCGORMPROJ_H
#ifndef _PCBUNDLELOADER_H
#define _PCBUNDLELOADER_H
/*
Description:
PCBundleLoader loads all PC bundles from all the paths that are stored in the
defaults under the key BundlePaths.
*/
#include <AppKit/AppKit.h>
#include <ProjectCenter/ProjectCenter.h>
@interface PCGormProj : NSObject <ProjectType>
@interface PCBundleLoader : NSObject
{
id delegate; // The PCAppController!
NSMutableArray *loadedBundles;
}
//----------------------------------------------------------------------------
// ProjectType
// Init and free methods
//----------------------------------------------------------------------------
+ (id)sharedCreator;
- (id)init;
- (void)dealloc;
- (Class)projectClass;
- (id)delegate;
- (void)setDelegate:(id)aDelegate;
- (NSString *)projectTypeName;
- (NSDictionary *)typeTable;
// Load all bundles found in the BundlePaths
- (void)loadBundles;
- (void)loadBundlesAtPath: (NSString *)path;
- (PCProject *)createProjectAt:(NSString *)path;
- (PCProject *)openProjectAt:(NSString *)path;
// Returns all loaded ProjectCenter bundles.
- (NSArray *)loadedBundles;
@end
@interface NSObject (BundleLoaderDelegates)
- (void)bundleLoader:(id)sender didLoadBundle:(NSBundle *)aBundle;
@end

170
Library/PCBundleLoader.m Normal file
View file

@ -0,0 +1,170 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2000-2002 Free Software Foundation
Author: Philippe C.D. Robert <probert@siggraph.org>
This file is part of GNUstep.
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#include "PCBundleLoader.h"
#include "PCDefines.h"
#include "PreferenceController.h"
#include "ProjectEditor.h"
#include "ProjectDebugger.h"
#include "PCLogController.h"
@interface PCBundleLoader (PrivateLoader)
- (void)loadAdditionalBundlesAt:(NSString *)path;
@end
@implementation PCBundleLoader (PrivateLoader)
- (void)loadAdditionalBundlesAt:(NSString *)path
{
NSBundle *bundle;
NSAssert(path,@"No valid bundle path specified!");
PCLogInfo(self, @"Loading bundle %@...", path);
if ((bundle = [NSBundle bundleWithPath:path]))
{
[loadedBundles addObject:bundle];
PCLogInfo(self, @"Bundle %@ successfully loaded!", path);
if (delegate
&&
[delegate respondsToSelector:@selector(bundleLoader:didLoadBundle:)])
{
[delegate bundleLoader:self didLoadBundle:bundle];
}
}
else
{
NSRunAlertPanel(@"Attention!",
@"Could not load %@!",
@"OK",nil,nil,path);
}
}
@end
@implementation PCBundleLoader
//----------------------------------------------------------------------------
// Init and free methods
//----------------------------------------------------------------------------
- (id)init
{
if ((self = [super init])) {
loadedBundles = [[NSMutableArray alloc] init];
}
return self;
}
- (void)dealloc
{
RELEASE(loadedBundles);
[super dealloc];
}
- (id)delegate
{
return delegate;
}
- (void)setDelegate:(id)aDelegate
{
delegate = aDelegate;
}
- (void) loadBundles
{
NSString *path = nil;
// Load bundles that comes with ProjectCenter
path = [[NSBundle mainBundle] resourcePath];
if (![[NSFileManager defaultManager] fileExistsAtPath: path])
{
[NSException raise: @"PCBundleLoaderPathException"
format: @"No valid bundles at path:\n%@", path];
return;
}
[self loadBundlesAtPath: path];
// Load third party bundles
path = [[NSUserDefaults standardUserDefaults] objectForKey:BundlePaths];
if (!path || [path isEqualToString: @""])
{
NSDictionary *env = [[NSProcessInfo processInfo] environment];
NSString *prefix = [env objectForKey: @"GNUSTEP_SYSTEM_ROOT"];
path = [prefix stringByAppendingPathComponent:
@"Library/ApplicationSupport/ProjectCenter"];
[[NSUserDefaults standardUserDefaults] setObject: path
forKey: BundlePaths];
[[NSUserDefaults standardUserDefaults] synchronize];
}
if (![[NSFileManager defaultManager] fileExistsAtPath: path])
{
PCLogInfo(self, @"No third party bundles at %@", path);
return;
}
else
{
PCLogInfo(self, @"Loading bundles at %@", path);
}
[self loadBundlesAtPath: path];
}
- (void) loadBundlesAtPath: (NSString *)path
{
NSEnumerator *enumerator;
NSString *bundleName;
NSArray *dir;
dir = [[NSFileManager defaultManager] directoryContentsAtPath: path];
enumerator = [dir objectEnumerator];
while ((bundleName = [enumerator nextObject]))
{
if ([[bundleName pathExtension] isEqualToString:@"bundle"])
{
NSString *fullPath;
fullPath = [NSString stringWithFormat:@"%@/%@",path,bundleName];
[self loadAdditionalBundlesAt:fullPath];
}
}
}
- (NSArray *)loadedBundles
{
return loadedBundles;
}
@end

59
Library/PCButton.h Normal file
View file

@ -0,0 +1,59 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2003 Free Software Foundation
Author: Serg Stoyan
This file is part of GNUstep.
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#ifndef _PCBUTTON_H_
#define _PCBUTTON_H_
#include <AppKit/AppKit.h>
/*
* Button
*/
@interface PCButton : NSButton
{
NSTrackingRectTag tRectTag;
NSTimer *ttTimer;
NSWindow *ttWindow;
NSPoint mouseLocation;
BOOL _hasTooltip;
}
- (void)setShowTooltip:(BOOL)yn;
- (void)updateTrackingRect;
@end
/*
* Button Cell
*/
@interface PCButtonCell : NSButtonCell
{
NSImage *tile;
}
@end
#endif

272
Library/PCButton.m Normal file
View file

@ -0,0 +1,272 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2003 Free Software Foundation
Author: Serg Stoyan
This file is part of GNUstep.
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#include "PCButton.h"
#include "PCDefines.h"
@implementation PCButton
- (id)initWithFrame:(NSRect)frameRect
{
self = [super initWithFrame:frameRect];
[self setCell:[[PCButtonCell alloc] init]];
[self setImagePosition: NSImageOnly];
[self setFont: [NSFont systemFontOfSize: 10.0]];
ttTimer = nil;
ttWindow = nil;
return self;
}
- (void)dealloc
{
if (_hasTooltip)
{
[[self superview] removeTrackingRect:tRectTag];
[ttTimer invalidate];
ttTimer = nil;
RELEASE(ttTimer);
}
if (ttWindow != nil)
{
RELEASE(ttWindow);
}
[super dealloc];
}
- (void)setFrame:(NSRect)frameRect
{
// NSLog (@"setFrame");
[super setFrame:frameRect];
if (_hasTooltip)
{
[self updateTrackingRect];
}
}
- (void)setShowTooltip:(BOOL)yn
{
_hasTooltip = yn;
if (_hasTooltip)
{
tRectTag = [[self superview] addTrackingRect:[self frame]
owner:self
userData:nil
assumeInside:NO];
[[self window] setAcceptsMouseMovedEvents:YES];
}
}
- (void)updateTrackingRect
{
[[self superview] removeTrackingRect:tRectTag];
tRectTag = [[self superview] addTrackingRect:[self frame]
owner:self
userData:nil
assumeInside:NO];
}
- (void)showTooltip:(NSTimer *)timer
{
NSAttributedString *attributedTitle = [self attributedTitle];
NSSize titleSize = [attributedTitle size];
// NSLog (@"showTooltip");
if (ttWindow == nil)
{
NSTextField *ttText;
NSRect windowRect;
NSRect titleRect;
NSRect contentRect;
windowRect = NSMakeRect(mouseLocation.x,
mouseLocation.y-16-(titleSize.height+3),
titleSize.width+10, titleSize.height+3);
titleRect = NSMakeRect(0,0, titleSize.width+10,titleSize.height+3);
/* windowRect = NSMakeRect(mouseLocation.x,
mouseLocation.y-16-(titleSize.height+3),
titleSize.width, titleSize.height);
titleRect = NSMakeRect(0,0, titleSize.width,titleSize.height);*/
contentRect = [NSWindow frameRectForContentRect:titleRect
styleMask:NSBorderlessWindowMask];
ttWindow = [[NSWindow alloc] initWithContentRect:windowRect
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreRetained
defer:YES];
[ttWindow setExcludedFromWindowsMenu:YES];
ttText = [[NSTextField alloc] initWithFrame:contentRect];
[ttText setEditable:NO];
[ttText setSelectable:NO];
[ttText setBezeled:NO];
[ttText setBordered:YES];
[ttText setBackgroundColor:[NSColor colorWithDeviceRed:1.0
green:1.0
blue:0.80
alpha:1.0]];
[ttText setFont:[self font]];
[ttText setStringValue:[self title]];
[[ttWindow contentView] addSubview:ttText];
}
else if (![ttWindow isVisible])
{
[ttWindow setFrameOrigin:
NSMakePoint(mouseLocation.x,
mouseLocation.y-16-(titleSize.height+3))];
[ttWindow orderFront:self];
}
}
- (void)mouseEntered:(NSEvent *)theEvent
{
// NSLog (@"mouseEntered");
if (ttTimer == nil)
{
ttTimer = [NSTimer
scheduledTimerWithTimeInterval:0.5
target:self
selector:@selector(showTooltip:)
userInfo:nil
repeats:YES];
}
}
- (void)mouseExited:(NSEvent *)theEvent
{
// NSLog (@"mouseExited");
if (ttTimer != nil)
{
// NSLog (@"-- invalidate");
[ttTimer invalidate];
ttTimer = nil;
}
}
- (void)mouseDown:(NSEvent *)theEvent
{
// NSLog (@"mouseDown");
if (ttTimer != nil)
{
// NSLog (@"-- invalidate");
[ttTimer invalidate];
ttTimer = nil;
}
[super mouseDown:theEvent];
}
- (void)mouseMoved:(NSEvent *)theEvent
{
mouseLocation = [NSEvent mouseLocation];
// NSLog (@"mouseMoved %f %f", mouseLocation.x, mouseLocation.y);
if (ttWindow && [ttWindow isVisible])
{
[ttWindow orderOut:self];
}
}
@end
@implementation PCButtonCell
- (id)init
{
self = [super init];
tile = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle]
pathForImageResource:@"ButtonTile"]];
return self;
}
- (void)dealloc
{
RELEASE(tile);
[super dealloc];
}
- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
{
[super drawInteriorWithFrame: cellFrame inView: controlView];
if (!_cell.is_highlighted)
{
NSPoint position;
NSImage *imageToDisplay;
unsigned mask = 0;
if ([controlView isFlipped])
{
position = NSMakePoint(cellFrame.origin.x+1,
cellFrame.size.height-2);
}
else
{
position = NSMakePoint(1, 2);
}
// Tile
[tile compositeToPoint:position
operation:NSCompositeSourceOver];
if (_cell.state)
mask = _showAltStateMask;
// Image
[_cell_image setBackgroundColor:[NSColor clearColor]];
[_altImage setBackgroundColor:[NSColor clearColor]];
if (mask & NSContentsCellMask)
{
imageToDisplay = _altImage;
}
else
{
imageToDisplay = _cell_image;
}
position.x = (cellFrame.size.width - [_cell_image size].width)/2;
position.y = (cellFrame.size.height - [_cell_image size].height)/2;
if (_cell.is_disabled)
{
[_cell_image dissolveToPoint:position fraction:0.5];
}
else
{
[imageToDisplay compositeToPoint:position
operation:NSCompositeSourceOver];
}
}
}
@end

227
Library/PCDefines.h Normal file
View file

@ -0,0 +1,227 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2000-2002 Free Software Foundation
Author: Philippe C.D. Robert <probert@siggraph.org>
This file is part of GNUstep.
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#ifndef _PCDefines_h_
#define _PCDefines_h_
#define PC_EXTERN extern
#define PRIVATE_EXTERN __private_extern__
#define SuccessSound @"SuccessSound"
#define FailureSound @"FailureSound"
#define RootBuildDirectory @"RootBuildDirectory"
#define PromptOnClean @"PromtOnClean"
#define SaveOnQuit @"SaveOnQuit"
#define KeepBackup @"KeepBackup"
#define AutoSavePeriod @"AutoSavePeriod"
#define TabBehaviour @"TabBehaviour"
#define TabSpaces @"TabSpaces"
#define PromptOnQuit @"PromtOnQuit"
#define DeleteCacheWhenQuitting @"DeleteBuildCacheWhenQuitting"
#define FullPathInFilePanels @"FullPathInFilePanels"
#define Debugger @"Debugger"
#define Editor @"Editor"
#define SeparateBuilder @"SeparateBuilder"
#define SeparateLauncher @"SeparateLauncher"
#define SeparateLoadedFiles @"SeparateLoadedFiles"
#define SeparateEditor @"SeparateEditor"
#define EditorLines @"EditorLines"
#define EditorColumns @"EditorColumns"
#define RememberWindows @"RememberWindows"
#define DisplayLog @"DisplayLog"
#define Compiler @"Compiler"
#define BundlePaths @"BundlePaths"
#define PCAppDidInitNotification @"PCAppDidInit"
#define PCAppWillTerminateNotification @"PCAppWillTerminate"
#define NIB_NOT_FOUND_EXCEPTION @"NibNotFoundException"
#define UNKNOWN_PROJECT_TYPE_EXCEPTION @"UnknownProjectTypeException"
#define NOT_A_PROJECT_TYPE_EXCEPTION @"NoProjectTypeCreatorException"
#define PROJECT_CREATION_EXCEPTION @"ProjectCreationException"
#define PROJECT_OPEN_FAILED_EXCEPTION @"ProjectOpenFailedException"
#define PROJECT_SAVE_FAILED_EXCEPTION @"ProjectSaveFailedException"
#define BUNDLE_MANAGER_EXCEPTION @"BundleManagerException"
//=============================================================================
// ==== MacOS X portability defines
//=============================================================================
#ifndef GNUSTEP_BASE_VERSION
#define RETAIN(object) [object retain]
#define RELEASE(object) [object release]
#define AUTORELEASE(object) [object autorelease]
#define TEST_RELEASE(object) ({ if (object) [object release]; })
#define ASSIGN(object,value) ({\
id __value = (id)(value); \
id __object = (id)(object); \
if (__value != __object) \
{ \
if (__value != nil) \
{ \
[__value retain]; \
} \
object = __value; \
if (__object != nil) \
{ \
[__object release]; \
} \
} \
})
#define DESTROY(object) ({ \
if (object) \
{ \
id __o = object; \
object = nil; \
[__o release]; \
} \
})
#define NSLocalizedString(key, comment) \
[[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil]
#define _(X) NSLocalizedString (X, @"")
#endif // GNUSTEP_BASE_VERSION
//
// ==== From PCProject.h
//
#ifndef IMAGE
#define IMAGE(X) [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForImageResource:(X)]] autorelease]
#endif
//=============================================================================
// ==== DEFINES
//=============================================================================
#define BUILD_ARGS_KEY @"BuildArgsKey"
#define BUILD_HOST_KEY @"BuildHostKey"
#define TARGET_MAKE @"Make"
#define TARGET_MAKE_DEBUG @"MakeDebug"
#define TARGET_MAKE_PROFILE @"MakeProfile"
#define TARGET_MAKE_INSTALL @"MakeInstall"
#define TARGET_MAKE_CLEAN @"MakeClean"
#define TARGET_MAKE_RPM @"MakeRPM"
#define BUILD_TAG 0
#define LAUNCH_TAG 1
#define EDITOR_TAG 2
#define FILES_TAG 3
#define FIND_TAG 4
#define INSPECTOR_TAG 5
//=============================================================================
// ==== Not used yet
//=============================================================================
#define TOUCHED_NOTHING (0)
#define TOUCHED_EVERYTHING (1 << 0)
#define TOUCHED_PROJECT_NAME (1 << 1)
#define TOUCHED_LANGUAGE (1 << 2)
#define TOUCHED_PROJECT_TYPE (1 << 3)
#define TOUCHED_INSTALL_DIR (1 << 4)
#define TOUCHED_ICON_NAMES (1 << 5)
#define TOUCHED_FILES (1 << 6)
#define TOUCHED_MAINNIB (1 << 7)
#define TOUCHED_PRINCIPALCLASS (1 << 8)
#define TOUCHED_TARGETS (1 << 9)
#define TOUCHED_PB_PROJECT (1 << 10)
#define TOUCHED_SYST_EXT (1 << 11)
#define TOUCHED_EXTENSION (1 << 12)
#define TOUCHED_PATHS (1 << 13)
typedef int PCProjInfoBits;
//=============================================================================
// ==== Project keys
//=============================================================================
#include <Foundation/Foundation.h>
static NSString * const PCClasses = @"CLASS_FILES";
static NSString * const PCHeaders = @"HEADER_FILES";
static NSString * const PCOtherSources = @"OTHER_SOURCES";
static NSString * const PCInterfaces = @"INTERFACES";
static NSString * const PCImages = @"IMAGES";
static NSString * const PCOtherResources = @"OTHER_RESOURCES";
static NSString * const PCSubprojects = @"SUBPROJECTS";
static NSString * const PCDocuFiles = @"DOCU_FILES";
static NSString * const PCSupportingFiles = @"SUPPORTING_FILES";
static NSString * const PCLibraries = @"LIBRARIES";
static NSString * const PCNonProject = @"NON_PROJECT_FILES";
static NSString * const PCGSMarkupFiles = @"INTERFACES";
static NSString * const PCBuildTool = @"BUILDTOOL";
static NSString * const PCCompilerOptions = @"COMPILEROPTIONS";
static NSString * const PCPreprocessorOptions = @"CPPOPTIONS";
static NSString * const PCCreationDate = @"CREATION_DATE";
static NSString * const PCInstallDir = @"INSTALLDIR";
static NSString * const PCLinkerOptions = @"LINKEROPTIONS";
static NSString * const PCLastEditing = @"LAST_EDITING";
static NSString * const PCObjCCompilerOptions = @"OBJC_COMPILEROPTIONS";
static NSString * const PCPrincipalClass = @"PRINCIPAL_CLASS";
static NSString * const PCAuthors = @"PROJECT_AUTHORS";
static NSString * const PCCopyright = @"PROJECT_COPYRIGHT";
static NSString * const PCCopyrightDescription = @"PROJECT_COPYRIGHT_DESC";
static NSString * const PCProjectCreator = @"PROJECT_CREATOR";
static NSString * const PCDescription = @"PROJECT_DESCRIPTION";
static NSString * const PCDocumentExtensions = @"PROJECT_DOCUMENTEXTENSIONS";
static NSString * const PCGroup = @"PROJECT_GROUP";
static NSString * const PCProjectMaintainer = @"PROJECT_MAINTAINER";
static NSString * const PCProjectName = @"PROJECT_NAME";
static NSString * const PCRelease = @"PROJECT_RELEASE";
static NSString * const PCSource = @"PROJECT_SOURCE";
static NSString * const PCSummary = @"PROJECT_SUMMARY";
static NSString * const PCProjectType = @"PROJECT_TYPE";
static NSString * const PCVersion = @"PROJECT_VERSION";
static NSString * const PCURL = @"PROJECT_URL";
static NSString * const PCSearchHeaders = @"SEARCH_HEADER_DIRS";
static NSString * const PCSearchLibs = @"SEARCH_LIB_DIRS";
// Application specific
static NSString * const PCAppIcon = @"APPLICATIONICON";
static NSString * const PCMainInterfaceFile = @"MAININTERFACE";
static NSString * const PCHelpFile = @"HELP_FILE";
// Library specific
static NSString * const PCHeadersToInstall = @"HEADERS_TO_INSTALL";
static NSString * const PCHeadersInstallDir = @"HEADERS_INSTALL_DIR";
// Bundle specific
static NSString * const PCBundleExtension = @"BUNDLE_EXTENSION";
// Tool specific
static NSString * const PCToolIcon = @"TOOLICON";
static NSString * const PCPackageName = @"PACKAGE_NAME";
static NSString * const PCLibraryVar = @"LIBRARY_VAR";
// Will be removed
static NSString * const PCProjectBuilderClass = @"PROJECT_BUILDER";
#endif // _PCDEFINES_H_

108
Library/PCEditor.h Normal file
View file

@ -0,0 +1,108 @@
/*
* PCEditor.h created by probert on 2002-01-29 20:37:28 +0000
*
* Project ProjectCenter
*
* Created with ProjectCenter - http://www.gnustep.org
*
* $Id$
*/
#ifndef _PCEditor_h_
#define _PCEditor_h_
#include <AppKit/AppKit.h>
@class PCProjectEditor;
@class PCEditorView;
@interface PCEditor : NSObject
{
PCProjectEditor *projectEditor;
NSScrollView *_extScrollView;
PCEditorView *_extEditorView;
NSScrollView *_intScrollView;
PCEditorView *_intEditorView;
NSTextStorage *_storage;
NSMutableString *_path;
NSString *_categoryPath;
NSWindow *_window;
BOOL _isEdited;
BOOL _isWindowed;
BOOL _isExternal;
}
// ===========================================================================
// ==== Initialization
// ===========================================================================
- (id)initWithPath:(NSString *)file
categoryPath:(NSString *)categoryPath
projectEditor:(PCProjectEditor *)projectEditor;
- (id)initExternalEditor:(NSString *)editor
withPath:(NSString *)file
projectEditor:(PCProjectEditor *)aProjectEditor;
- (void)dealloc;
- (void)show;
- (void)setWindowed:(BOOL)yn;
- (BOOL)isWindowed;
// ===========================================================================
// ==== Accessor methods
// ===========================================================================
- (PCProjectEditor *)projectEditor;
- (NSWindow *)editorWindow;
- (PCEditorView *)editorView;
- (NSView *)componentView;
- (NSString *)path;
- (void)setPath:(NSString *)path;
- (NSString *)categoryPath;
- (BOOL)isEdited;
- (void)setIsEdited:(BOOL)yn;
// ===========================================================================
// ==== Object managment
// ===========================================================================
- (BOOL)saveFileIfNeeded;
- (BOOL)saveFile;
- (BOOL)saveFileTo:(NSString *)path;
- (BOOL)revertFileToSaved;
- (BOOL)closeFile:(id)sender save:(BOOL)save;
- (BOOL)editorShouldClose;
// ===========================================================================
// ==== Window delegate
// ===========================================================================
- (BOOL)windowShouldClose:(id)sender;
- (void)windowDidBecomeKey:(NSNotification *)aNotification;
- (void)windowDidResignKey:(NSNotification *)aNotification;
// ===========================================================================
// ==== TextView (_intEditorView, _extEditorView) delegate
// ===========================================================================
- (void)textDidChange:(NSNotification *)aNotification;
- (BOOL)becomeFirstResponder;
- (BOOL)resignFirstResponder;
@end
@interface PCEditor (UInterface)
- (void)_createWindow;
- (void)_createInternalView;
- (PCEditorView *)_createEditorViewWithFrame:(NSRect)fr;
@end
/*@interface NSObject (PCEditorDelegate)
- (void)editorDidClose:(id)sender;
- (void)setBrowserPath:(NSString *)file category:(NSString *)category;
@end*/
#endif // _PCEDITOR_H_

564
Library/PCEditor.m Normal file
View file

@ -0,0 +1,564 @@
/*
* PCEditor.m created by probert on 2002-01-29 20:37:27 +0000
*
* Project ProjectCenter
*
* Created with ProjectCenter - http://www.gnustep.org
*
* $Id$
*/
#include "PCDefines.h"
#include "PCProjectEditor.h"
#include "PCEditor.h"
#include "PCEditorView.h"
#include "ProjectComponent.h"
#include "PCLogController.h"
@implementation PCEditor (UInterface)
- (void)_createWindow
{
unsigned int style;
NSRect rect;
float windowWidth;
PCLogInfo(self, @"[_createWindow]");
style = NSTitledWindowMask
| NSClosableWindowMask
| NSMiniaturizableWindowMask
| NSResizableWindowMask;
windowWidth = [[NSFont userFixedPitchFontOfSize:0.0] widthOfString:@"A"];
windowWidth *= 80;
windowWidth += 35+80;
rect = NSMakeRect(100,100,windowWidth,320);
_window = [[NSWindow alloc] initWithContentRect:rect
styleMask:style
backing:NSBackingStoreBuffered
defer:YES];
[_window setReleasedWhenClosed:YES];
[_window setMinSize:NSMakeSize(512,320)];
[_window setDelegate:self];
rect = [[_window contentView] frame];
// Scroll view
_extScrollView = [[NSScrollView alloc] initWithFrame:rect];
[_extScrollView setHasHorizontalScroller:NO];
[_extScrollView setHasVerticalScroller:YES];
[_extScrollView setAutoresizingMask:
(NSViewWidthSizable|NSViewHeightSizable)];
rect = [[_extScrollView contentView] frame];
// Editor view
_extEditorView = [self _createEditorViewWithFrame:rect];
// Include editor view
[_extScrollView setDocumentView:_extEditorView];
[_extEditorView setNeedsDisplay:YES];
RELEASE(_extEditorView);
// Include scroll view
[_window setContentView:_extScrollView];
[_window makeFirstResponder:_extEditorView];
RELEASE(_extScrollView);
}
- (void)_createInternalView
{
NSRect rect = NSMakeRect(0,0,512,320);
// Scroll view
_intScrollView = [[NSScrollView alloc] initWithFrame:rect];
[_intScrollView setHasHorizontalScroller:NO];
[_intScrollView setHasVerticalScroller:YES];
[_intScrollView setBorderType:NSBezelBorder];
[_intScrollView setAutoresizingMask:(NSViewWidthSizable|NSViewHeightSizable)];
rect = [[_intScrollView contentView] frame];
// Text view
_intEditorView = [self _createEditorViewWithFrame:rect];
/*
* Setting up ext view / scroll view / window
*/
[_intScrollView setDocumentView:_intEditorView];
[_intEditorView setNeedsDisplay:YES];
RELEASE(_intEditorView);
}
- (PCEditorView *)_createEditorViewWithFrame:(NSRect)fr
{
PCEditorView *ev;
NSTextContainer *tc;
NSLayoutManager *lm;
/*
* setting up the objects needed to manage the view but using the
* shared textStorage.
*/
lm = [[NSLayoutManager alloc] init];
tc = [[NSTextContainer alloc] initWithContainerSize:fr.size];
[lm addTextContainer:tc];
RELEASE(tc);
[_storage addLayoutManager:lm];
RELEASE(lm);
ev = [[PCEditorView alloc] initWithFrame:fr textContainer:tc];
[ev setEditor:self];
[ev setMinSize:NSMakeSize( 0, 0)];
[ev setMaxSize:NSMakeSize(1e7, 1e7)];
[ev setRichText:YES];
[ev setEditable:YES];
[ev setVerticallyResizable:YES];
[ev setHorizontallyResizable:NO];
[ev setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
[ev setTextContainerInset:NSMakeSize( 5, 5)];
[[ev textContainer] setWidthTracksTextView:YES];
[[ev textContainer] setContainerSize:NSMakeSize(fr.size.width, 1e7)];
return AUTORELEASE(ev);
}
@end
@implementation PCEditor
// ===========================================================================
// ==== Initialization
// ===========================================================================
- (id)initWithPath:(NSString *)file
categoryPath:(NSString *)categoryPath
projectEditor:(PCProjectEditor *)aProjectEditor
{
if ((self = [super init]))
{
NSString *t;
NSAttributedString *as;
NSDictionary *at;
NSFont *ft;
projectEditor = aProjectEditor;
_isEdited = NO;
_isWindowed = NO;
_window = nil;
_path = [file copy];
_categoryPath = [categoryPath copy];
ft = [NSFont userFixedPitchFontOfSize:0.0];
at = [NSDictionary dictionaryWithObject:ft forKey:NSFontAttributeName];
t = [NSString stringWithContentsOfFile:file];
as = [[NSAttributedString alloc] initWithString:t attributes:at];
_storage = [[NSTextStorage alloc] init];
[_storage setAttributedString:as];
RELEASE(as);
if (categoryPath) // category == nil if we're non project editor
{
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
if (![[ud objectForKey:SeparateEditor] isEqualToString:@"YES"])
{
[self _createInternalView];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(textDidChange:)
name:NSTextDidChangeNotification
object:_intEditorView];
}
}
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(textDidChange:)
name:NSTextDidChangeNotification
object:_extEditorView];
// Inform about file opening
[[NSNotificationCenter defaultCenter]
postNotificationName:PCEditorDidOpenNotification
object:self];
}
return self;
}
- (id)initExternalEditor:(NSString *)editor
withPath:(NSString *)file
projectEditor:(PCProjectEditor *)aProjectEditor
{
NSTask *editorTask = nil;
NSArray *ea = nil;
NSMutableArray *args = nil;
NSString *app = nil;
if (!(self = [super init]))
{
return nil;
}
projectEditor = aProjectEditor;
_extScrollView = nil;
_extEditorView = nil;
_intScrollView = nil;
_intEditorView = nil;
_storage = nil;
_path = [file copy];
_categoryPath = nil;
_window = nil;
_isEdited = NO;
_isWindowed = NO;
_isExternal = YES;
// Task
ea = [editor componentsSeparatedByString:@" "];
args = [NSMutableArray arrayWithArray:ea];
app = [ea objectAtIndex:0];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector (externalEditorDidClose:)
name:NSTaskDidTerminateNotification
object:nil];
editorTask = [[NSTask alloc] init];
[editorTask setLaunchPath:app];
[args removeObjectAtIndex:0];
[args addObject:file];
[editorTask setArguments:args];
[editorTask launch];
// AUTORELEASE(editorTask);
// Inform about file opening
[[NSNotificationCenter defaultCenter]
postNotificationName:PCEditorDidOpenNotification
object:self];
return self;
}
- (void)externalEditorDidClose:(NSNotification *)aNotif
{
NSString *path = [[[aNotif object] arguments] lastObject];
if (![path isEqualToString:_path])
{
PCLogError(self, @"external editor task terminated");
return;
}
PCLogStatus(self, @"Our Editor task terminated");
// Inform about closing
[[NSNotificationCenter defaultCenter]
postNotificationName:PCEditorDidCloseNotification
object:self];
}
- (void)dealloc
{
NSLog(@"PCEditor: dealloc");
[[NSNotificationCenter defaultCenter] removeObserver:self];
// _window is setReleasedWhenClosed:YES
RELEASE(_path);
RELEASE(_categoryPath);
RELEASE(_intScrollView);
[super dealloc];
}
- (void)show
{
if (_isWindowed)
{
[_window makeKeyAndOrderFront:nil];
}
}
- (void)setWindowed:(BOOL)yn
{
if ( (yn && _isWindowed) || (!yn && !_isWindowed) )
{
return;
}
if (yn && !_isWindowed)
{
[self _createWindow];
[_window setTitle:[NSString stringWithFormat: @"%@",
[_path stringByAbbreviatingWithTildeInPath]]];
}
else if (!yn && _isWindowed)
{
[_window close];
}
_isWindowed = yn;
}
- (BOOL)isWindowed
{
return _isWindowed;
}
// ===========================================================================
// ==== Accessor methods
// ===========================================================================
- (PCProjectEditor *)projectEditor
{
return projectEditor;
}
- (NSWindow *)editorWindow
{
return _window;
}
- (PCEditorView *)editorView
{
return _intEditorView;
}
- (NSView *)componentView
{
return _intScrollView;
}
- (NSString *)path
{
return _path;
}
- (void)setPath:(NSString *)path
{
[_path autorelease];
_path = [path copy];
}
- (NSString *)categoryPath
{
return _categoryPath;
}
- (BOOL)isEdited
{
return _isEdited;
}
- (void)setIsEdited:(BOOL)yn
{
if (_window)
{
[_window setDocumentEdited:yn];
}
_isEdited = yn;
}
// ===========================================================================
// ==== Object managment
// ===========================================================================
- (BOOL)saveFileIfNeeded
{
if ((_isEdited))
{
return [self saveFile];
}
return YES;
}
- (BOOL)saveFile
{
[self setIsEdited:NO];
// Operate on the text storage!
return [[_storage string] writeToFile:_path atomically:YES];
}
- (BOOL)saveFileTo:(NSString *)path
{
// Operate on the text storage!
return [[_storage string] writeToFile:path atomically:YES];
}
- (BOOL)revertFileToSaved
{
NSString *text = [NSString stringWithContentsOfFile:_path];
NSAttributedString *as = nil;
NSDictionary *at = nil;
NSFont *ft = nil;
// This is temporary
ft = [NSFont userFixedPitchFontOfSize:0.0];
at = [NSDictionary dictionaryWithObject:ft forKey:NSFontAttributeName];
as = [[NSAttributedString alloc] initWithString:text attributes:at];
[self setIsEdited:NO];
// Operate on the text storage!
[_storage setAttributedString:as];
RELEASE(as);
[_intEditorView setNeedsDisplay:YES];
[_extEditorView setNeedsDisplay:YES];
return YES;
}
- (BOOL)closeFile:(id)sender save:(BOOL)save
{
if ((save == NO) || [self editorShouldClose])
{
// Close window first if visible
if (_isWindowed && [_window isVisible] && (sender != _window))
{
[_window close];
}
// Inform about closing
[[NSNotificationCenter defaultCenter]
postNotificationName:PCEditorDidCloseNotification
object:self];
return YES;
}
return NO;
}
- (BOOL)editorShouldClose
{
if (_isEdited)
{
BOOL ret;
if (_isWindowed && [_window isVisible])
{
[_window makeKeyAndOrderFront:self];
}
ret = NSRunAlertPanel(@"Close File",
@"File %@ has been modified",
@"Save and Close", @"Don't save", @"Cancel",
[_path lastPathComponent]);
if (ret == YES)
{
if ([self saveFile] == NO)
{
NSRunAlertPanel(@"Alert",
@"Error when saving file '%@'!",
@"OK", nil, nil, [_path lastPathComponent]);
return NO;
}
else
{
return YES;
}
}
else if (ret == NO) // Close but don't save
{
return YES;
}
else // Cancel closing
{
return NO;
}
[self setIsEdited:NO];
}
return YES;
}
// ===========================================================================
// ==== Window delegate
// ===========================================================================
- (BOOL)windowShouldClose:(id)sender
{
if ([sender isEqual:_window])
{
if (_intScrollView)
{
// Just close if this file also displayed in int view
_isWindowed = NO;
return YES;
}
else
{
return [self closeFile:_window save:YES];
}
}
return NO;
}
- (void)windowDidBecomeKey:(NSNotification *)aNotification
{
if ([[aNotification object] isEqual:_window] && [_window isVisible])
{
[_window makeFirstResponder:_extEditorView];
}
}
- (void)windowDidResignKey:(NSNotification *)aNotification
{
if ([[aNotification object] isEqual:_window] && [_window isVisible])
{
[_window makeFirstResponder:_window];
}
}
// ===========================================================================
// ==== TextView (_intEditorView, _extEditorView) delegate
// ===========================================================================
- (void)textDidChange:(NSNotification *)aNotification
{
id object = [aNotification object];
if ([object isKindOfClass:[PCEditorView class]]
&& (object == _intEditorView || object == _extEditorView))
{
[self setIsEdited:YES];
}
}
- (BOOL)becomeFirstResponder
{
NSLog(@"PCEditor: becomeFirstResponder");
[[NSNotificationCenter defaultCenter]
postNotificationName:PCEditorDidBecomeActiveNotification
object:self];
return YES;
}
- (BOOL)resignFirstResponder
{
[[NSNotificationCenter defaultCenter]
postNotificationName:PCEditorDidResignActiveNotification
object:self];
return YES;
}
@end

View file

@ -0,0 +1,44 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2000-2002 Free Software Foundation
Author: Philippe C.D. Robert <probert@siggraph.org>
This file is part of GNUstep.
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#ifndef _PCEDITORVIEW_HIGHLIGHTING_H
#define _PCEDITORVIEW_HIGHLIGHTING_H
#include <Foundation/Foundation.h>
@class PCEditorView;
@interface PCEditorView (Highlighting)
- (void)colouriseKeyword:(NSString *)keyword;
- (void)colouriseKeywords:(NSArray *)keywords;
- (void)colouriseStrings;
- (void)colouriseCharStrings;
- (void)colouriseComments;
- (void)colouriseCPPComments;
@end
#endif

View file

@ -20,8 +20,6 @@
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$Id$
*/
#include "PCEditorView.h"

View file

@ -20,8 +20,6 @@
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$Id$
*/
#ifndef _PCEDITORVIEW_H
@ -40,12 +38,10 @@ typedef enum _PCTabFlags {
@interface PCEditorView : NSTextView
{
PCEditor *editor;
NSScanner *scanner;
@private
NSRange range;
NSArray *_keywords;
PCEditor *editor;
NSRange range;
NSArray *_keywords;
#ifndef GNUSTEP_BASE_VERSION
id _textStorage;

View file

@ -20,25 +20,36 @@
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$Id$
*/
#include "PCEditorView.h"
#include "PCEditor.h"
#include "PCEditorView.h"
#include "PCEditorView+Highlighting.h"
#include "PCEditorController.h"
@implementation PCEditorView
static BOOL shouldHighlight = NO;
static int _tabFlags = PCTab4Sp;
- (BOOL) becomeFirstResponder
- (BOOL)becomeFirstResponder
{
return [editor becomeFirstResponder];
}
- (BOOL)resignFirstResponder
{
return [editor resignFirstResponder];
}
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
{
return YES;
}
//=============================================================================
// ==== Class methods
//=============================================================================
+ (void)setTabBehaviour:(int)tabFlags
{
_tabFlags = tabFlags;
@ -59,6 +70,10 @@ static int _tabFlags = PCTab4Sp;
return shouldHighlight;
}
//=============================================================================
// ==== Init
//=============================================================================
- (id)initWithFrame:(NSRect)frameRect textContainer:(NSTextContainer*)tc
{
if ((self = [super initWithFrame:frameRect textContainer:tc]))
@ -94,55 +109,59 @@ static int _tabFlags = PCTab4Sp;
- (void)dealloc
{
if (scanner)
{
[scanner release];
}
{
[scanner release];
}
[_keywords release];
[super dealloc];
}
//=============================================================================
// ==== Accessor methods
//=============================================================================
- (void)setEditor:(PCEditor *)anEditor
{
editor = anEditor;
editor = anEditor;
}
- (void)setString:(NSString *)aString
{
[scanner autorelease];
scanner = [[NSScanner alloc] initWithString:aString];
[scanner autorelease];
scanner = [[NSScanner alloc] initWithString:aString];
[super setString:aString];
[super setString:aString];
if( shouldHighlight )
if( shouldHighlight )
{
[self highlightText];
[self highlightText];
}
}
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
{
return YES;
}
//=============================================================================
// ==== Text handling
//=============================================================================
- (void)insertText:(id)aString
{
NSRange txtRange = NSMakeRange(0, [[self textStorage] length]);
NSRange txtRange = NSMakeRange(0, [[self textStorage] length]);
[super insertText:aString];
[super insertText:aString];
if( shouldHighlight )
if( shouldHighlight )
{
[[self textStorage] invalidateAttributesInRange:txtRange];
[self highlightTextInRange:txtRange];
[[self textStorage] invalidateAttributesInRange:txtRange];
[self highlightTextInRange:txtRange];
}
}
- (void)highlightText
{
NSRange txtRange = NSMakeRange(0, [[self textStorage] length]);
NSRange txtRange = NSMakeRange(0, [[self textStorage] length]);
[self highlightTextInRange:txtRange];
[self highlightTextInRange:txtRange];
}
- (void)highlightTextInRange:(NSRange)txtRange

View file

@ -20,19 +20,23 @@
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$Id$
*/
#ifndef _PCBASEFILETYPE_H
#define _PCBASEFILETYPE_H
#ifndef _PCFileCreator_h
#define _PCFileCreator_h
#include <AppKit/AppKit.h>
#include <ProjectCenter/FileCreator.h>
#define ProtocolFile @"Objective-C Protocol"
#define ObjCClass @"Objective-C Class"
#define ObjCHeader @"Objective-C Header"
#define CFile @"C File"
#define CHeader @"C Header"
#define GSMarkupFile @"GNUstep Markup"
@class PCProject;
@interface PCBaseFileType : NSObject <FileCreator>
@interface PCFileCreator : NSObject
{
NSMutableString *file;
}
@ -42,10 +46,13 @@
- (NSString *)name;
- (NSDictionary *)creatorDictionary;
- (NSDictionary *)createFileOfType:(NSString *)type path:(NSString *)path project:(PCProject *)aProject;
// The implementation needs some heavy cleanup!
// The implementation needs some heavy cleanup!
- (NSDictionary *)createFileOfType:(NSString *)type
path:(NSString *)path
project:(PCProject *)aProject;
- (void)replaceTagsInFileAtPath:(NSString *)newFile withProject:(PCProject *)aProject type:(NSString *)aType;
- (void)replaceTagsInFileAtPath:(NSString *)newFile
withProject:(PCProject *)aProject;
@end

308
Library/PCFileCreator.m Normal file
View file

@ -0,0 +1,308 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2001 Free Software Foundation
Author: Philippe C.D. Robert <phr@3dkit.org>
This file is part of GNUstep.
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#include "PCDefines.h"
#include "PCFileCreator.h"
#include "PCProject.h"
#include "PCLogController.h"
@implementation PCFileCreator
static PCFileCreator *_creator = nil;
static NSString *_name = @"FileCreator";
static NSDictionary *dict = nil;
+ (id)sharedCreator
{
if (!_creator)
{
NSDictionary *classDict;
NSDictionary *headerDict;
NSDictionary *ccDict;
NSDictionary *chDict;
NSDictionary *protocolDict;
NSDictionary *gsmarkupDict;
NSString *descr;
_creator = [[[self class] alloc] init];
// Setting up the dictionary needed for registration!
descr = [NSString stringWithString:@"Generic Objective-C class.\n\nThis is a plain subclass of NSObject which includes only Foundation.h."];
classDict = [NSDictionary dictionaryWithObjectsAndKeys:
_creator,@"Creator",
PCClasses,@"ProjectKey",
descr,@"TypeDescription",
nil];
descr = [NSString stringWithString:@"Generic Objective-C header.\n\nThis is a plain interface subclassing NSObject. The file includes Foundation.h"];
headerDict =[NSDictionary dictionaryWithObjectsAndKeys:
_creator,@"Creator",
PCHeaders,@"ProjectKey",
descr,@"TypeDescription",
nil];
descr = [NSString stringWithString:@"Generic ANSI-C implementation file.\n\nThis file contains no Objective-C dependency in any form."];
ccDict = [NSDictionary dictionaryWithObjectsAndKeys:
_creator,@"Creator",
PCOtherSources,@"ProjectKey",
descr,@"TypeDescription",
nil];
descr = [NSString stringWithString:@"Generic ANSI-C header.\n\nThis file contains no Objective-C dependency in any form."];
chDict = [NSDictionary dictionaryWithObjectsAndKeys:
_creator,@"Creator",
PCHeaders,@"ProjectKey",
descr,@"TypeDescription",
nil];
descr = [NSString stringWithString:@"Generic Objective-C protocol.\n\nThis is common Objective-C protocol, comparable i.e. to a Java interface."];
protocolDict = [NSDictionary dictionaryWithObjectsAndKeys:
_creator,@"Creator",
PCHeaders,@"ProjectKey",
descr,@"TypeDescription",
nil];
descr = [NSString stringWithString:@"Generic GSMarkup File.\n\nThis is the interface description of GNUstep Renaissance."];
gsmarkupDict =[NSDictionary dictionaryWithObjectsAndKeys:
_creator,@"Creator",
PCGSMarkupFiles,@"ProjectKey",
descr,@"TypeDescription",
nil];
dict = [[NSDictionary alloc] initWithObjectsAndKeys:
ccDict,CFile,
chDict,CHeader,
protocolDict,ProtocolFile,
headerDict,ObjCHeader,
classDict,ObjCClass,
gsmarkupDict,GSMarkupFile,
nil];
}
return _creator;
}
- (NSString *)name
{
return _name;
}
- (NSDictionary *)creatorDictionary
{
return dict;
}
- (NSDictionary *)createFileOfType:(NSString *)type
path:(NSString *)path
project:(PCProject *)aProject
{
NSFileManager *fm = [NSFileManager defaultManager];
NSString *_file;
NSString *newFile = nil;
NSMutableDictionary *files;
NSBundle *bundle;
// A class and possibly a header
files = [NSMutableDictionary dictionaryWithCapacity:2];
PCLogStatus(self, @"create %@ at %@", type, path);
bundle = [NSBundle bundleForClass:[self class]];
newFile = [path copy];
/*
* Objective-C Class
*/
if ([type isEqualToString:ObjCClass])
{
_file = [bundle pathForResource:@"class" ofType:@"template"];
if ([[path pathExtension] isEqual: @"m"] == NO)
{
newFile = [path stringByAppendingPathExtension:@"m"];
}
[fm copyPath:_file toPath:newFile handler:nil];
[files setObject:ObjCClass forKey:newFile];
[self replaceTagsInFileAtPath:newFile withProject:aProject];
// Header must be created as well!
newFile = [path stringByAppendingPathExtension:@"h"];
_file = [bundle pathForResource:@"header" ofType:@"template"];
[fm copyPath:_file toPath:newFile handler:nil];
[self replaceTagsInFileAtPath:newFile withProject:aProject];
[files setObject:ObjCHeader forKey:newFile];
}
/*
* Objective-C Header
*/
else if ([type isEqualToString:ObjCHeader])
{
_file = [bundle pathForResource:@"header" ofType:@"template"];
if ([[path pathExtension] isEqual: @"h"] == NO)
{
newFile = [path stringByAppendingPathExtension:@"h"];
}
[fm copyPath:_file toPath:newFile handler:nil];
[self replaceTagsInFileAtPath:newFile withProject:aProject];
[files setObject:ObjCHeader forKey:newFile];
}
/*
* C File
*/
else if ([type isEqualToString:CFile])
{
_file = [bundle pathForResource:@"cfile" ofType:@"template"];
if ([[path pathExtension] isEqual: @"c"] == NO)
{
newFile = [path stringByAppendingPathExtension:@"c"];
}
[fm copyPath:_file toPath:newFile handler:nil];
[files setObject:CFile forKey:newFile];
[self replaceTagsInFileAtPath:newFile withProject:aProject];
// Header should be created as well.
newFile = [path stringByAppendingPathExtension:@"h"];
_file = [bundle pathForResource:@"cheader" ofType:@"template"];
[fm copyPath:_file toPath:newFile handler:nil];
[self replaceTagsInFileAtPath:newFile withProject:aProject];
[files setObject:CHeader forKey:newFile];
}
/*
* C Header
*/
else if ([type isEqualToString:CHeader])
{
_file = [bundle pathForResource:@"cheader" ofType:@"template"];
if ([[path pathExtension] isEqual: @"h"] == NO)
{
newFile = [path stringByAppendingPathExtension:@"h"];
}
[fm copyPath:_file toPath:newFile handler:nil];
[self replaceTagsInFileAtPath:newFile withProject:aProject];
[files setObject:CHeader forKey:newFile];
}
/*
* GSMarkup
*/
else if ([type isEqualToString:GSMarkupFile])
{
_file = [bundle pathForResource:@"gsmarkup" ofType:@"template"];
if ([[path pathExtension] isEqual: @"gsmarkup"] == NO)
{
newFile = [path stringByAppendingPathExtension:@"gsmarkup"];
}
[fm copyPath:_file toPath:newFile handler:nil];
[files setObject:GSMarkupFile forKey:newFile];
}
/*
* Objective-C Protocol
*/
else if ([type isEqualToString:ProtocolFile])
{
_file = [bundle pathForResource:@"protocol" ofType:@"template"];
if ([[path pathExtension] isEqual: @"h"] == NO)
{
newFile = [path stringByAppendingPathExtension:@"h"];
}
[fm copyPath:_file toPath:newFile handler:nil];
[self replaceTagsInFileAtPath:newFile withProject:aProject];
[files setObject:ProtocolFile forKey:newFile];
}
/*
* Notify the browser!
*/
[[NSNotificationCenter defaultCenter]
postNotificationName:@"ProjectDictDidChangeNotification"
object:self];
return files;
}
- (void)replaceTagsInFileAtPath:(NSString *)newFile
withProject:(PCProject *)aProject
{
NSString *projectName = [aProject projectName];
NSString *date = [[NSCalendarDate calendarDate] description];
int year = [[NSCalendarDate calendarDate] yearOfCommonEra];
NSString *aFile = [newFile lastPathComponent];
NSString *UCfn = [[aFile stringByDeletingPathExtension] uppercaseString];
NSString *fn = [aFile stringByDeletingPathExtension];
NSRange subRange;
file = [[NSMutableString stringWithContentsOfFile:newFile] retain];
while ((subRange = [file rangeOfString:@"$FULLFILENAME$"]).length)
{
[file replaceCharactersInRange:subRange withString:aFile];
}
while ((subRange = [file rangeOfString:@"$FILENAME$"]).length)
{
[file replaceCharactersInRange:subRange withString:fn];
}
while ((subRange = [file rangeOfString:@"$UCFILENAME$"]).length)
{
[file replaceCharactersInRange:subRange withString:UCfn];
}
while ((subRange = [file rangeOfString:@"$USERNAME$"]).length)
{
[file replaceCharactersInRange:subRange withString:NSUserName()];
}
while ((subRange = [file rangeOfString:@"$FULLUSERNAME$"]).length)
{
[file replaceCharactersInRange:subRange withString:NSFullUserName()];
}
while ((subRange = [file rangeOfString:@"$PROJECTNAME$"]).length)
{
[file replaceCharactersInRange:subRange withString:projectName];
}
while ((subRange = [file rangeOfString:@"$DATE$"]).length)
{
[file replaceCharactersInRange:subRange withString:date];
}
while ((subRange = [file rangeOfString:@"$YEAR$"]).length)
{
[file replaceCharactersInRange:subRange
withString:[[NSNumber numberWithInt:year] stringValue]];
}
[file writeToFile:newFile atomically:YES];
[file autorelease];
}
@end

View file

@ -20,26 +20,36 @@
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$Id$
*/
#ifndef _PCFILEMANAGER_H
#define _PCFILEMANAGER_H
#ifndef _PCFileManager_h
#define _PCFileManager_h
#include <Foundation/Foundation.h>
#include <AppKit/AppKit.h>
@class PCProject;
@class PCProjectManager;
@interface PCFileManager : NSObject
{
id newFileWindow;
id fileTypePopup;
id newFileName;
id descrView;
PCProjectManager *projectManager;
id delegate; // PCProjectManager
id delegate; // PCProjectManager
NSDictionary *creators;
NSMutableDictionary *creators;
NSMutableDictionary *typeDescr;
// New File in Project panel
IBOutlet NSPanel *newFilePanel;
IBOutlet NSImageView *nfImage;
IBOutlet NSPopUpButton *nfTypePB;
IBOutlet NSTextView *nfDescriptionTV;
IBOutlet NSTextField *nfNameField;
IBOutlet NSButton *nfCancleButton;
IBOutlet NSButton *nfCreateButton;
NSOpenPanel *addFilesPanel;
NSBox *fileTypeAccessaryView;
NSPopUpButton *fileTypePopup;
}
//==============================================================================
@ -52,46 +62,43 @@
// ==== Init and free
//==============================================================================
- (id)init;
- (id)initWithProjectManager:(PCProjectManager *)aProjectManager;
- (void)dealloc;
- (void)awakeFromNib;
// ===========================================================================
// ==== Delegate
// ===========================================================================
- (id)delegate;
- (void)setDelegate:(id)aDelegate;
// ===========================================================================
// ==== File stuff
// ===========================================================================
- (void)showAddFileWindow;
// Shows NSOpenPanel and return selected files if any
- (NSMutableArray *)filesForOpenOfType:(NSArray *)types
multiple:(BOOL)yn
title:(NSString *)title
accView:(NSView *)accessoryView;
- (NSString *)fileForSaveOfType:(NSArray *)types
title:(NSString *)title
accView:(NSView *)accessoryView;
- (void)showNewFileWindow;
- (void)buttonsPressed:(id)sender;
- (void)popupChanged:(id)sender;
// Return NO if coping of any file failed
- (BOOL)copyFiles:(NSArray *)files intoDirectory:(NSString *)directory;
// Return NO if removing of any file failed
- (BOOL)removeFiles:(NSArray *)files fromDirectory:(NSString *)directory;
- (void)createFile;
- (void)registerCreatorsWithObjectsAndKeys:(NSDictionary *)dict;
@end
@interface NSObject (FileManagerDelegates)
@interface PCFileManager (UInterface)
- (NSString *)fileManager:(id)sender willCreateFile:(NSString *)aFile withKey:(NSString *)key;
// Returns the correct, full path - or nil!
- (void)showNewFilePanel;
- (void)closeNewFilePanel:(id)sender;
- (void)createFile:(id)sender;
- (void)newFilePopupChanged:(id)sender;
- (void)fileManager:(id)sender didCreateFile:(NSString *)aFile withKey:(NSString *)key;
- (id)fileManagerWillAddFiles:(id)sender;
// Is invoked to get the currently active project!
- (BOOL)fileManager:(id)sender shouldAddFile:(NSString *)file forKey:(NSString *)key;
- (void)fileManager:(id)sender didAddFile:(NSString *)file forKey:(NSString *)key;
- (void)_createAddFilesPanel;
- (NSMutableArray *)filesForAdd;
- (void)filesForAddPopupClicked:(id)sender;
@end

489
Library/PCFileManager.m Normal file
View file

@ -0,0 +1,489 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2000-2002 Free Software Foundation
Author: Philippe C.D. Robert <probert@siggraph.org>
This file is part of GNUstep.
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#include "PCDefines.h"
#include "PCFileManager.h"
#include "PCFileCreator.h"
#include "PCProjectManager.h"
#include "PCProject.h"
#include "PCProjectBrowser.h"
#include "PCServer.h"
#include "PCLogController.h"
@implementation PCFileManager
// ===========================================================================
// ==== Class methods
// ===========================================================================
static PCFileManager *_mgr = nil;
+ (PCFileManager *)fileManager
{
if (!_mgr)
{
_mgr = [[PCFileManager alloc] init];
}
return _mgr;
}
// ===========================================================================
// ==== Init and free
// ===========================================================================
- (id)initWithProjectManager:(PCProjectManager *)aProjectManager
{
if ((self = [super init]))
{
projectManager = aProjectManager;
creators = [[PCFileCreator sharedCreator] creatorDictionary];
RETAIN(creators);
}
return self;
}
- (void)dealloc
{
RELEASE(creators);
RELEASE(newFilePanel);
[super dealloc];
}
// ===========================================================================
// ==== File stuff
// ===========================================================================
- (NSMutableArray *)filesForOpenOfType:(NSArray *)types
multiple:(BOOL)yn
title:(NSString *)title
accView:(NSView *)accessoryView
{
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
NSString *lastOpenDir = [ud objectForKey:@"LastOpenDirectory"];
NSOpenPanel *openPanel = nil;
int retval;
openPanel = [NSOpenPanel openPanel];
[openPanel setAllowsMultipleSelection:yn];
[openPanel setCanChooseFiles:YES];
[openPanel setCanChooseDirectories:NO];
// [openPanel setDelegate:self];
[openPanel setTitle:title];
[openPanel setAccessoryView:accessoryView];
if (!lastOpenDir)
{
lastOpenDir = NSHomeDirectory();
}
retval = [openPanel runModalForDirectory:lastOpenDir file:nil types:types];
if (retval == NSOKButton)
{
[ud setObject:[openPanel directory] forKey:@"LastOpenDirectory"];
return [[[openPanel filenames] mutableCopy] autorelease];
}
return nil;
}
- (NSString *)fileForSaveOfType:(NSArray *)types
title:(NSString *)title
accView:(NSView *)accessoryView
{
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
NSString *lastOpenDir = [ud objectForKey:@"LastOpenDirectory"];
NSSavePanel *savePanel = nil;
int retval;
savePanel = [NSSavePanel savePanel];
[savePanel setDelegate:self];
[savePanel setTitle:title];
// [savePanel setAccessoryView:nil];
[savePanel setAccessoryView:accessoryView];
if (!lastOpenDir)
{
lastOpenDir = NSHomeDirectory();
}
retval = [savePanel runModalForDirectory:lastOpenDir file:nil];
if (retval == NSOKButton)
{
[ud setObject:[savePanel directory] forKey:@"LastOpenDirectory"];
return [[[savePanel filename] mutableCopy] autorelease];
}
return nil;
}
- (BOOL)copyFiles:(NSArray *)files intoDirectory:(NSString *)directory
{
NSEnumerator *enumerator;
NSString *file = nil;
NSString *fileName = nil;
NSString *path = nil;
if (!files)
{
return NO;
}
enumerator = [files objectEnumerator];
while ((file = [enumerator nextObject]))
{
NSFileManager *fm = [NSFileManager defaultManager];
fileName = [file lastPathComponent];
path = [directory stringByAppendingPathComponent:fileName];
if (![fm fileExistsAtPath:path])
{
if (![fm copyPath:file toPath:path handler:nil])
{
return NO;
}
}
}
return YES;
}
- (BOOL)removeFiles:(NSArray *)files fromDirectory:(NSString *)directory
{
NSEnumerator *filesEnum = nil;
NSString *file = nil;
NSString *path = nil;
NSFileManager *fm = [NSFileManager defaultManager];
if (!files)
{
return NO;
}
filesEnum = [files objectEnumerator];
while ((file = [filesEnum nextObject]))
{
path = [directory stringByAppendingPathComponent:file];
if (![fm removeFileAtPath:path handler:nil])
{
return NO;
}
}
return YES;
}
- (void)createFile
{
NSString *path = nil;
NSString *fileName = [nfNameField stringValue];
NSString *fileType = [nfTypePB titleOfSelectedItem];
NSString *key = [[creators objectForKey:fileType] objectForKey:@"ProjectKey"];
PCLogInfo(self, @"[createFile] %@", fileName);
path = [projectManager fileManager:self
willCreateFile:fileName
withKey:key];
PCLogInfo(self, @"creating file at %@", path);
// Create file
if (path)
{
NSDictionary *newFiles = nil;;
PCFileCreator *creator = nil;
PCProject *project = [projectManager activeProject];
NSEnumerator *enumerator;
NSString *aFile;
creator = [[creators objectForKey:fileType] objectForKey:@"Creator"];
if (!creator)
{
NSRunAlertPanel(@"Attention!",
@"Could not create %@. The creator is missing!",
@"OK",nil,nil,fileName);
return;
}
// Do it finally...
newFiles = [creator createFileOfType:fileType path:path project:project];
// Key: name of file
enumerator = [[newFiles allKeys] objectEnumerator];
while ((aFile = [enumerator nextObject]))
{
NSString *theType = [newFiles objectForKey:aFile];
NSString *theKey = [[creators objectForKey:theType]
objectForKey:@"ProjectKey"];
[projectManager fileManager:self didCreateFile:aFile withKey:theKey];
}
}
}
@end
@implementation PCFileManager (UInterface)
// -- "New File in Project" Panel
- (void)showNewFilePanel
{
if (!newFilePanel)
{
if ([NSBundle loadNibNamed:@"NewFile" owner:self] == NO)
{
PCLogError(self, @"error loading NewFile NIB!");
return;
}
[newFilePanel setFrameAutosaveName:@"NewFile"];
if (![newFilePanel setFrameUsingName: @"NewFile"])
{
[newFilePanel center];
}
[newFilePanel center];
[nfImage setImage:[NSApp applicationIconImage]];
[nfTypePB setRefusesFirstResponder:YES];
[nfTypePB removeAllItems];
[nfTypePB addItemsWithTitles:
[[creators allKeys]
sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]];
[nfTypePB selectItemAtIndex:0];
[nfCancleButton setRefusesFirstResponder:YES];
[nfCreateButton setRefusesFirstResponder:YES];
}
[self newFilePopupChanged:nfTypePB];
[newFilePanel makeKeyAndOrderFront:self];
[nfNameField setStringValue:@""];
[newFilePanel makeFirstResponder:nfNameField];
}
- (void)closeNewFilePanel:(id)sender
{
[newFilePanel orderOut:self];
}
- (void)createFile:(id)sender
{
[self createFile];
[self closeNewFilePanel:self];
}
- (void)newFilePopupChanged:(id)sender
{
NSString *type = [sender titleOfSelectedItem];
if (type)
{
[nfDescriptionTV setString:
[[creators objectForKey:type] objectForKey:@"TypeDescription"]];
}
}
- (void)controlTextDidChange:(NSNotification *)aNotif
{
if ([aNotif object] != nfNameField)
{
return;
}
// TODO: Add check for valid file names
if ([[nfNameField stringValue] length] > 0)
{
[nfCreateButton setEnabled:YES];
}
else
{
[nfCreateButton setEnabled:NO];
}
}
// --- "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 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];
RELEASE(fileTypePopup);
// Panel
addFilesPanel = [NSOpenPanel openPanel];
[addFilesPanel setAllowsMultipleSelection:YES];
[addFilesPanel setCanChooseFiles:YES];
[addFilesPanel setCanChooseDirectories:NO];
[addFilesPanel setDelegate:self];
[addFilesPanel setAccessoryView:fileTypeAccessaryView];
}
}
- (NSMutableArray *)filesForAdd
{
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
NSString *lastOpenDir = [ud objectForKey:@"LastOpenDirectory"];
PCProject *project = [projectManager rootActiveProject];
NSString *selectedCategory = nil;
int retval;
[self _createAddFilesPanel];
selectedCategory = [[project projectBrowser] nameOfSelectedCategory];
if ([selectedCategory isEqualToString:@"Subprojects"])
{
[addFilesPanel setCanChooseFiles:NO];
[addFilesPanel setCanChooseDirectories:YES];
}
[fileTypePopup selectItemWithTitle:selectedCategory];
[self filesForAddPopupClicked:self];
if (!lastOpenDir)
{
lastOpenDir = NSHomeDirectory();
}
retval = [addFilesPanel runModalForDirectory:lastOpenDir
file:nil
types:nil];
if (retval == NSOKButton)
{
[ud setObject:[addFilesPanel directory] forKey:@"LastOpenDirectory"];
return [[addFilesPanel filenames] mutableCopy];
}
return nil;
}
- (void)filesForAddPopupClicked:(id)sender
{
NSString *fileType = [fileTypePopup titleOfSelectedItem];
[addFilesPanel setTitle:[NSString stringWithFormat:@"Add %@",fileType]];
if ([fileType isEqualToString:@"Interfaces"])
{
[addFilesPanel setCanChooseDirectories:YES];
}
[addFilesPanel display];
}
// ============================================================================
// ==== NSOpenPanel and NSSavePanel delegate
// ============================================================================
// If file name already in project -- don't show it!
- (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename
{
NSFileManager *fileManager = [NSFileManager defaultManager];
PCProject *project = [projectManager activeProject];
NSArray *fileTypes = nil;
NSString *fileType = nil;
NSString *categoryKey = nil;
BOOL isDir;
if (sender != addFilesPanel)
{
// This is not "Add Files" panel (Open... or Save...)
return YES;
}
// Directories must be shown
if ([fileManager fileExistsAtPath:filename isDirectory:&isDir] && isDir)
{
return YES;
}
if (!(fileType = [fileTypePopup titleOfSelectedItem]))
{
PCLogWarning(self, @"Selected File type is nil!");
return YES;
}
categoryKey = [project keyForCategory:fileType];
fileTypes = [project fileTypesForCategoryKey:categoryKey];
if (fileTypes == nil)
{
PCLogWarning(self,
@"Project file types is nil! Category: %@", categoryKey);
return YES;
}
if (fileTypes && [fileTypes containsObject:[filename pathExtension]])
{
NSString *filePath;
NSString *projectPath;
filePath = [[filename stringByDeletingLastPathComponent]
stringByResolvingSymlinksInPath];
projectPath = [[project projectPath] stringByResolvingSymlinksInPath];
if ([filePath isEqualToString:projectPath])
{
return NO;
}
return YES;
}
return NO;
}
// Test if we should accept file name selected or entered
- (BOOL)panel:(id)sender isValidFilename:(NSString *)filename
{
if ([[sender className] isEqualToString:@"NSOpenPanel"])
{
;
}
else if ([[sender className] isEqualToString:@"NSSavePanel"])
{
;
}
return YES;
}
@end

44
Library/PCLaunchPanel.h Normal file
View file

@ -0,0 +1,44 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2003 Free Software Foundation
Author: Serg Stoyan <stoyan@on.com.ua>
This file is part of GNUstep.
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#ifndef _PCLaunchPanel_h
#define _PCLaunchPanel_h
#include <AppKit/AppKit.h>
@class PCProjectManager;
@interface PCLaunchPanel : NSPanel
{
PCProjectManager *projectManager;
PCProject *currentProject;
NSBox *contentBox;
NSBox *emptyBox;
}
- (id)initWithProjectManager:(PCProjectManager *)aManager;
@end
#endif

148
Library/PCLaunchPanel.m Normal file
View file

@ -0,0 +1,148 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2003 Free Software Foundation
Author: Serg Stoyan <stoyan@on.com.ua>
This file is part of GNUstep.
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#include "PCProjectManager.h"
#include "PCProject.h"
#include "PCProjectLauncher.h"
#include "PCLaunchPanel.h"
#include "PCLogController.h"
@implementation PCLaunchPanel
- (id)initWithProjectManager:(PCProjectManager *)aManager
{
PCProjectLauncher *projectLauncher = nil;
PCProject *activeProject = nil;
projectManager = aManager;
activeProject = [projectManager rootActiveProject];
projectLauncher = [activeProject projectLauncher];
projectLauncher = [[aManager activeProject] projectLauncher];
self = [super initWithContentRect: NSMakeRect (0, 300, 480, 322)
styleMask: (NSTitledWindowMask
| NSClosableWindowMask
| NSResizableWindowMask)
backing: NSBackingStoreRetained
defer: YES];
[self setMinSize: NSMakeSize(440, 222)];
[self setFrameAutosaveName: @"ProjectLauncher"];
[self setReleasedWhenClosed: NO];
[self setHidesOnDeactivate: NO];
[self setTitle: [NSString stringWithFormat:
@"%@ - Launch", [activeProject projectName]]];
contentBox = [[NSBox alloc] init];
[contentBox setContentViewMargins:NSMakeSize(8.0, 0.0)];
[contentBox setTitlePosition:NSNoTitle];
[contentBox setBorderType:NSNoBorder];
[super setContentView:contentBox];
// Empty content view of contentBox
emptyBox = [[NSBox alloc] init];
[emptyBox setContentViewMargins:NSMakeSize(0.0, 0.0)];
[emptyBox setTitlePosition:NSNoTitle];
[emptyBox setBorderType:NSLineBorder];
[contentBox setContentView:emptyBox];
// Track project switching
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(activeProjectDidChange:)
name:PCActiveProjectDidChangeNotification
object:nil];
if (![self setFrameUsingName: @"ProjectLauncher"])
{
[self center];
}
return self;
}
- (void)dealloc
{
NSLog (@"PCLaunchPanel: dealloc");
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
- (void)orderFront:(id)sender
{
PCProject *activeProject = [projectManager rootActiveProject];
NSView *launcherView = [[activeProject projectLauncher] componentView];
if (!([contentBox contentView] == launcherView))
{
[contentBox setContentView:launcherView];
[contentBox display];
}
PCLogInfo(self, @"orderFront: %@ -> %@",
launcherView, [launcherView superview]);
[super orderFront:self];
}
- (void)close
{
PCLogInfo(self, @"close: %@", [contentBox contentView]);
[contentBox setContentView:emptyBox];
PCLogInfo(self, @"close: %@", [contentBox contentView]);
[super close];
}
- (void)activeProjectDidChange:(NSNotification *)aNotif
{
PCProject *rootProject = [projectManager rootActiveProject];
if (rootProject == currentProject)
{
return;
}
currentProject = rootProject;
if (!rootProject)
{
[contentBox setContentView:emptyBox];
}
else
{
[self setTitle: [NSString stringWithFormat:
@"%@ - Launch", [rootProject projectName]]];
[contentBox
setContentView:[[rootProject projectLauncher] componentView]];
}
}
@end

View file

@ -0,0 +1,44 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2003 Free Software Foundation
Author: Serg Stoyan <stoyan@on.com.ua>
This file is part of GNUstep.
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#ifndef _PCLoadedFilesPanel_h
#define _PCLoadedFilesPanel_h
#include <AppKit/AppKit.h>
@class PCProjectManager;
@interface PCLoadedFilesPanel : NSPanel
{
PCProjectManager *projectManager;
PCProject *currentProject;
NSBox *contentBox;
NSBox *emptyBox;
}
- (id)initWithProjectManager:(PCProjectManager *)aManager;
@end
#endif

View file

@ -0,0 +1,150 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2003 Free Software Foundation
Author: Serg Stoyan <stoyan@on.com.ua>
This file is part of GNUstep.
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#include "PCProjectManager.h"
#include "PCProject.h"
#include "PCProjectLoadedFiles.h"
#include "PCLoadedFilesPanel.h"
#include "PCLogController.h"
@implementation PCLoadedFilesPanel
- (id)initWithProjectManager:(PCProjectManager *)aManager
{
PCProjectLoadedFiles *projectLoadedFiles = nil;
PCProject *activeProject = nil;
projectManager = aManager;
activeProject = [projectManager rootActiveProject];
currentProject = activeProject;
projectLoadedFiles = [activeProject projectLoadedFiles];
PCLogStatus(self, @"[init]");
self = [super initWithContentRect: NSMakeRect (0, 300, 220, 322)
styleMask: (NSTitledWindowMask
| NSClosableWindowMask
| NSResizableWindowMask)
backing: NSBackingStoreRetained
defer: YES];
// [self setFloatingPanel:YES];
[self setMinSize: NSMakeSize(120, 23)];
[self setFrameAutosaveName: @"LoadedFiles"];
[self setReleasedWhenClosed: NO];
[self setHidesOnDeactivate: YES];
[self setTitle: [NSString stringWithFormat:
@"%@ - Loaded Files", [activeProject projectName]]];
// Panel's content view
contentBox = [[NSBox alloc] init];
[contentBox setContentViewMargins:NSMakeSize(0.0, 0.0)];
[contentBox setTitlePosition:NSNoTitle];
[contentBox setBorderType:NSNoBorder];
[self setContentView:contentBox];
// Empty content view of contentBox
emptyBox = [[NSBox alloc] init];
[emptyBox setContentViewMargins:NSMakeSize(0.0, 0.0)];
[emptyBox setTitlePosition:NSNoTitle];
[emptyBox setBorderType:NSLineBorder];
[contentBox setContentView:emptyBox];
// Track project switching
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(activeProjectDidChange:)
name:PCActiveProjectDidChangeNotification
object:nil];
if (![self setFrameUsingName: @"LoadedFiles"])
{
[self center];
}
return self;
}
- (void)dealloc
{
NSLog(@"PCLoadedFilesPanel: dealloc");
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
- (void)orderFront:(id)sender
{
PCProject *activeProject = [projectManager rootActiveProject];
NSView *filesView = [[activeProject projectLoadedFiles] componentView];
if (!([contentBox contentView] == filesView))
{
[contentBox setContentView:filesView];
[contentBox display];
}
[super orderFront:self];
}
- (void)close
{
[contentBox setContentView:emptyBox];
[super close];
}
- (void)activeProjectDidChange:(NSNotification *)aNotif
{
PCProject *rootProject = [projectManager rootActiveProject];
PCLogInfo(self, @"rootProject %@ currentProject %@",
[rootProject projectName], [currentProject projectName]);
if (rootProject == currentProject)
{
return;
}
PCLogInfo(self, @"1--- rootProject %@ currentProject %@",
[rootProject projectName], [currentProject projectName]);
currentProject = rootProject;
if (!rootProject)
{
[contentBox setContentView:emptyBox];
}
else
{
[self setTitle: [NSString stringWithFormat:
@"%@ - Loaded Files", [rootProject projectName]]];
[contentBox
setContentView:[[rootProject projectLoadedFiles] componentView]];
}
}
@end

View file

@ -0,0 +1,61 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2002 Free Software Foundation
Author: Philippe C.D. Robert <phr@3dkit.org>
This file is part of GNUstep.
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#ifndef _PCMAKEFILEFACTORY_H_
#define _PCMAKEFILEFACTORY_H_
#include <Foundation/Foundation.h>
@class PCProject;
@interface PCMakefileFactory : NSObject
{
NSMutableString *mfile;
NSString *pnme;
}
+ (PCMakefileFactory *)sharedFactory;
- (void)createMakefileForProject:(NSString *)prName;
- (BOOL)createPreambleForProject:(PCProject *)project;
- (BOOL)createPostambleForProject:(PCProject *)project;
- (void)appendString:(NSString *)aString;
- (void)appendHeaders:(NSArray *)array;
- (void)appendHeaders:(NSArray *)array forTarget: (NSString *)target;
- (void)appendClasses:(NSArray *)array;
- (void)appendClasses:(NSArray *)array forTarget: (NSString *)target;
- (void)appendOtherSources:(NSArray *)array;
- (void)appendOtherSources:(NSArray *)array forTarget: (NSString *)target;
- (void)appendResources;
- (void)appendResourceItems:(NSArray *)array;
- (void)appendSubprojects:(NSArray*)array;
- (NSData *)encodedMakefile;
@end
#endif // _PCMAKEFILEFACTORY_H_

331
Library/PCMakefileFactory.m Normal file
View file

@ -0,0 +1,331 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2002 Free Software Foundation
Author: Philippe C.D. Robert <phr@3dkit.org>
This file is part of GNUstep.
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#include "PCDefines.h"
#include "PCProject.h"
#include "PCMakefileFactory.h"
#define COMMENT_HEADERS @"\n\n#\n# Header files\n#\n"
#define COMMENT_RESOURCES @"\n\n#\n# Resource files\n#\n"
#define COMMENT_CLASSES @"\n\n#\n# Class files\n#\n"
#define COMMENT_CFILES @"\n\n#\n# C files\n#\n"
#define COMMENT_SUBPROJECTS @"\n\n#\n# Subprojects\n#\n"
#define COMMENT_APP @"\n\n#\n# Main application\n#\n"
#define COMMENT_LIBRARIES @"\n\n#\n# Additional libraries\n#\n"
#define COMMENT_BUNDLE @"\n\n#\n# Bundle\n#\n"
#define COMMENT_LIBRARY @"\n\n#\n# Library\n#\n"
#define COMMENT_TOOL @"\n\n#\n# Tool\n#\n"
@implementation PCMakefileFactory
static PCMakefileFactory *_factory = nil;
+ (PCMakefileFactory *)sharedFactory
{
static BOOL isInitialised = NO;
if( isInitialised == NO )
{
_factory = [[PCMakefileFactory alloc] init];
isInitialised = YES;
}
return _factory;
}
- (void)createMakefileForProject:(NSString *)prName
{
NSAssert( prName, @"No project name given!");
AUTORELEASE( mfile );
mfile = [[NSMutableString alloc] init];
AUTORELEASE( pnme );
pnme = [prName copy];
[mfile appendString:@"#\n"];
[mfile appendString:@"# GNUmakefile - Generated by ProjectCenter\n"];
[mfile appendString:@"#\n"];
[mfile appendString:@"\ninclude $(GNUSTEP_MAKEFILES)/common.make\n"];
}
- (BOOL)createPreambleForProject:(PCProject *)project
{
NSMutableString *mfp = [[NSMutableString alloc] init];
NSString *mfl = nil;
NSArray *array = nil;
NSDictionary *projectDict = [project projectDict];
NSString *projectPath = [project projectPath];
// Create the new file
[mfp appendString:@"#\n"];
[mfp appendString:@"# GNUmakefile.preamble - Generated by ProjectCenter\n"];
[mfp appendString:@"#\n\n"];
// Preprocessor flags
[mfp appendString:@"# Additional flags to pass to the preprocessor\n"];
[mfp appendString:
[NSString stringWithFormat:@"ADDITIONAL_CPPFLAGS += %@\n\n",
[projectDict objectForKey:PCPreprocessorOptions]]];
// Objective C compiler flags
[mfp appendString:@"# Additional flags to pass to Objective C compiler\n"];
[mfp appendString:
[NSString stringWithFormat:@"ADDITIONAL_OBJCFLAGS += %@\n\n",
[projectDict objectForKey:PCObjCCompilerOptions]]];
// C compiler flags
[mfp appendString:@"# Additional flags to pass to C compiler\n"];
[mfp appendString:
[NSString stringWithFormat:@"ADDITIONAL_CFLAGS += %@\n\n",
[projectDict objectForKey:PCCompilerOptions]]];
// Linker flags
[mfp appendString:@"# Additional flags to pass to the linker\n"];
[mfp appendString:
[NSString stringWithFormat:@"ADDITIONAL_LDFLAGS += %@ ",
[projectDict objectForKey:PCLinkerOptions]]];
array = [projectDict objectForKey:PCLibraries];
if (array && [array count])
{
NSString *tmp;
NSEnumerator *enumerator = [array objectEnumerator];
while ((tmp = [enumerator nextObject]))
{
if (![tmp isEqualToString:@"gnustep-base"] &&
![tmp isEqualToString:@"gnustep-gui"])
{
[mfp appendString:[NSString stringWithFormat:@"-l%@ ",tmp]];
}
}
}
[mfp appendString:@"\n\n"];
// Directories where to search headers
[mfp appendString:
@"# Additional include directories the compiler should search\n"];
[mfp appendString:@"ADDITIONAL_INCLUDE_DIRS += "];
array = [projectDict objectForKey:PCSearchHeaders];
if (array && [array count])
{
NSString *tmp;
NSEnumerator *enumerator = [array objectEnumerator];
while ((tmp = [enumerator nextObject]))
{
[mfp appendString:[NSString stringWithFormat:@"-I%@ ",tmp]];
}
}
[mfp appendString:@"\n\n"];
// Directories where to search libraries
[mfp appendString:
@"# Additional library directories the linker should search\n"];
[mfp appendString:@"ADDITIONAL_LIB_DIRS += "];
array = [projectDict objectForKey:PCSearchLibs];
if (array && [array count])
{
NSString *tmp;
NSEnumerator *enumerator = [array objectEnumerator];
while ((tmp = [enumerator nextObject]))
{
[mfp appendString:[NSString stringWithFormat:@"-L%@ ",tmp]];
}
}
[mfp appendString:@"\n\n"];
// [mfp appendString:[projectDict objectForKey:PCLibraries]];
// Write the new file to disc!
mfl = [projectPath stringByAppendingPathComponent:@"GNUmakefile.preamble"];
if ([mfp writeToFile:mfl atomically:YES])
{
return YES;
}
return NO;
}
- (BOOL)createPostambleForProject:(PCProject *)project
{
NSBundle *bundle = nil;
NSString *template = nil;
NSString *postamble = nil;
NSFileManager *fm = [NSFileManager defaultManager];
bundle = [NSBundle bundleForClass:[self class]];
template = [bundle pathForResource:@"postamble" ofType:@"template"];
postamble = [[project projectPath]
stringByAppendingPathComponent:@"GNUmakefile.postamble"];
return [fm copyPath:template toPath:postamble handler:nil];
}
- (void)appendString:(NSString *)aString
{
NSAssert( mfile, @"No valid makefile available!");
NSAssert( aString, @"No valid string!");
[mfile appendString:aString];
}
- (void)appendHeaders:(NSArray *)array
{
[self appendHeaders: array forTarget: pnme];
}
- (void)appendHeaders:(NSArray *)array forTarget: (NSString *)target
{
[self appendString:COMMENT_HEADERS];
[self appendString:[NSString stringWithFormat:@"%@_HEADER_FILES = ",
target]];
if( array && [array count] )
{
NSString *tmp;
NSEnumerator *enumerator = [array objectEnumerator];
while ( (tmp = [enumerator nextObject]) )
{
[self appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]];
}
}
}
- (void)appendClasses:(NSArray *)array
{
[self appendClasses: array forTarget: pnme];
}
- (void)appendClasses:(NSArray *)array forTarget: (NSString *)target
{
[self appendString:COMMENT_CLASSES];
[self appendString:[NSString stringWithFormat:@"%@_OBJC_FILES = ", target]];
if( array && [array count] )
{
NSString *tmp;
NSEnumerator *enumerator = [array objectEnumerator];
while ( (tmp = [enumerator nextObject] ))
{
[self appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]];
}
}
}
- (void)appendOtherSources:(NSArray *)array
{
[self appendOtherSources: array forTarget: pnme];
}
- (void)appendOtherSources:(NSArray *)array forTarget: (NSString *)target
{
NSMutableArray *marray = nil;
NSEnumerator *oenum;
NSString *file;
[self appendString:COMMENT_CFILES];
[self appendString:[NSString stringWithFormat:@"%@_C_FILES = ", target]];
if ( array == nil || [array count] == 0)
return;
/* Other Sources can have both m files and c files (possibly others?). */
oenum = [array objectEnumerator];
while ((file = [oenum nextObject]))
{
if ([file hasSuffix: @".m"])
{
if (marray == nil)
marray = [NSMutableArray arrayWithCapacity: 2];
[marray addObject: file];
}
else /* if ([f hasSuffix: @".c"]) */
{
[self appendString:[NSString stringWithFormat:@"\\\n%@ ",file]];
}
}
[self appendString: @"\n"];
[self appendString:[NSString stringWithFormat:@"%@_OBJC_FILES += ",pnme]];
if ( marray )
{
NSString *file;
NSEnumerator *enumerator = [marray objectEnumerator];
while ( (file = [enumerator nextObject]) )
{
[self appendString:[NSString stringWithFormat:@"\\\n%@ ", file]];
}
}
}
- (void)appendResources
{
[self appendString:COMMENT_RESOURCES];
[self appendString:[NSString stringWithFormat:@"%@_RESOURCE_FILES = ",pnme]];
}
- (void)appendResourceItems:(NSArray *)array
{
NSString *tmp;
NSEnumerator *enumerator = [array objectEnumerator];
while ((tmp = [enumerator nextObject]))
{
[self appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]];
}
}
- (void)appendSubprojects:(NSArray*)array
{
[self appendString:COMMENT_SUBPROJECTS];
[self appendString:@"SUBPROJECTS = "];
if (array && [array count])
{
NSString *tmp;
NSEnumerator *enumerator = [array objectEnumerator];
while ((tmp = [enumerator nextObject]))
{
tmp = [tmp stringByAppendingPathExtension:@"subproj"];
[self appendString:[NSString stringWithFormat:@"\\\n%@ ",tmp]];
}
}
}
- (NSData *)encodedMakefile
{
NSAssert( mfile, @"No valid makefile available!");
return [mfile dataUsingEncoding:[NSString defaultCStringEncoding]];
}
@end

220
Library/PCProject.h Normal file
View file

@ -0,0 +1,220 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2000-2002 Free Software Foundation
Author: Philippe C.D. Robert <probert@siggraph.org>
This file is part of GNUstep.
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#ifndef _PCProject_h_
#define _PCProject_h_
#include <AppKit/AppKit.h>
#include "PCProjectManager.h"
@class PCProjectManager;
@class PCProjectWindow;
@class PCProjectBrowser;
@class PCProjectLoadedFiles;
@class PCProjectInspector;
@class PCProjectBuilder;
@class PCProjectLauncher;
@class PCProjectEditor;
#ifndef GNUSTEP_BASE_VERSION
@protocol ProjectBuilder;
#else
#include <ProjectCenter/ProjectBuilder.h>
#endif
extern NSString *PCProjectDictDidChangeNotification;
extern NSString *PCProjectDictDidSaveNotification;
@interface PCProject : NSObject
{
PCProjectManager *projectManager;
PCProjectWindow *projectWindow;
PCProjectBrowser *projectBrowser;
PCProjectLoadedFiles *projectLoadedFiles;
PCProjectEditor *projectEditor;
PCProjectBuilder *projectBuilder;
PCProjectLauncher *projectLauncher;
NSView *builderContentView;
NSView *debuggerContentView;
NSMutableDictionary *projectDict;
NSString *projectName;
NSString *projectPath;
NSArray *rootKeys; // e.g. CLASS_FILES
NSArray *rootCategories; // e.g. Classes
NSDictionary *rootEntries; // Initialised by subclasses
NSMutableDictionary *buildOptions;
BOOL editorIsActive;
PCProject *activeSubproject;
// Subproject
NSMutableArray *loadedSubprojects;
BOOL isSubproject;
PCProject *rootProject;
PCProject *superProject;
}
// ============================================================================
// ==== Init and free
// ============================================================================
- (id)init;
- (id)initWithProjectDictionary:(NSDictionary *)dict path:(NSString *)path;
- (PCProjectManager *)projectManager;
- (void)setProjectManager:(PCProjectManager *)aManager;
- (BOOL)close:(id)sender;
- (void)dealloc;
- (BOOL)saveProjectWindowsAndPanels;
// ============================================================================
// ==== Accessory methods
// ============================================================================
- (PCProjectManager *)projectManager;
- (PCProjectWindow *)projectWindow;
- (PCProjectBrowser *)projectBrowser;
- (PCProjectLoadedFiles *)projectLoadedFiles;
- (PCProjectBuilder *)projectBuilder;
- (PCProjectLauncher *)projectLauncher;
- (PCProjectEditor *)projectEditor;
- (void)setProjectDictObject:(id)object forKey:(NSString *)key;
- (NSString *)projectName;
- (void)setProjectName:(NSString *)aName;
- (BOOL)isProjectChanged;
// ===========================================================================
// ==== Can be overriden
// ===========================================================================
// Project Attributes Inspector
- (NSView *)projectAttributesView;
- (Class)builderClass;
- (NSString *)projectDescription; // Project type
- (BOOL)isExecutable;
- (NSString *)execToolName;
- (NSArray *)buildTargets;
- (NSArray *)sourceFileKeys;
- (NSArray *)resourceFileKeys;
- (NSArray *)otherKeys;
- (NSArray *)allowableSubprojectTypes;
- (NSArray *)defaultLocalizableKeys;
- (NSArray *)localizableKeys;
- (BOOL)isEditableCategory:(NSString *)category;
- (NSArray *)fileTypesForCategoryKey:(NSString *)key;
- (NSString *)categoryKeyForFileType:(NSString *)type;
- (NSString *)dirForCategoryKey:(NSString *)key;
- (NSString *)complementaryTypeForType:(NSString *)type;
// Subclasses need to call this before their customised implementation!
- (BOOL)writeMakefile;
// ============================================================================
// ==== File Handling
// ============================================================================
// Remove path from "file" and handle special cases like libraries
- (NSString *)projectFileFromFile:(NSString *)file forKey:(NSString *)type;
// Returns YES if type is a valid key and file is not contained in the
// project already
- (BOOL)doesAcceptFile:(NSString *)file forKey:(NSString *)key;
- (BOOL)addAndCopyFiles:(NSArray *)files forKey:(NSString *)key;
- (void)addFiles:(NSArray *)files forKey:(NSString *)key;
- (BOOL)removeFiles:(NSArray *)files forKey:(NSString *)key;
- (BOOL)renameFile:(NSString *)fromFile toFile:(NSString *)toFile;
// ============================================================================
// ==== Project handling
// ============================================================================
- (BOOL)assignProjectDict:(NSDictionary *)aDict;
- (NSDictionary *)projectDict;
- (void)setProjectPath:(NSString *)aPath;
- (NSString *)projectPath;
- (NSArray *)rootKeys;
- (NSArray *)rootCategories;
- (NSDictionary *)rootEntries;
- (NSString *)keyForCategory:(NSString *)category;
- (NSString *)categoryForKey:(NSString *)key;
- (BOOL)save;
- (BOOL)writeSpecFile;
- (BOOL)isValidDictionary:(NSDictionary *)aDict;
- (void)updateProjectDict;
// Validates the project dictionary and inserts missing keys if needed. It
// calls isValidDictionary to validate.
- (void)validateProjectDict;
// ============================================================================
// ==== Subprojects
// ============================================================================
- (NSArray *)loadedSubprojects;
- (PCProject *)activeSubproject;
- (BOOL)isSubproject;
- (void)setIsSubproject:(BOOL)yn;
- (PCProject *)superProject;
- (void)setSuperProject:(PCProject *)project;
- (PCProject *)subprojectWithName:(NSString *)name;
- (void)addSubproject:(PCProject *)aSubproject;
- (void)addSubprojectWithName:(NSString *)name;
- (BOOL)removeSubproject:(PCProject *)aSubproject;
- (BOOL)removeSubprojectWithName:(NSString *)subprojectName;
@end
@interface PCProject (CategoryPaths)
- (NSArray *)contentAtCategoryPath:(NSString *)categoryPath;
- (BOOL)hasChildrenAtCategoryPath:(NSString *)keyPath;
- (NSString *)rootCategoryForCategoryPath:(NSString *)categoryPath;
- (NSString *)categoryForCategoryPath:(NSString *)categoryPath;
- (NSString *)keyForRootCategoryInCategoryPath:(NSString *)categoryPath;
- (NSString *)keyForCategoryPath:(NSString *)categoryPath;
@end
#endif

1335
Library/PCProject.m Normal file

File diff suppressed because it is too large Load diff

View file

@ -20,8 +20,6 @@
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$Id$
*/
#ifndef _PCBROWSERCONTROLLER_H
@ -33,34 +31,53 @@ extern NSString *PCBrowserDidSetPathNotification;
@class PCProject;
@interface PCBrowserController : NSObject
@interface PCProjectBrowser : NSObject
{
id browser;
PCProject *project;
NSBrowser *browser;
}
// ============================================================================
// ==== Intialization & deallocation
// ============================================================================
- (id)initWithProject:(PCProject *)aProject;
- (void)dealloc;
// ============================================================================
// ==== Accessory methods
// ============================================================================
- (NSView *)view;
- (NSString *)nameOfSelectedFile;
- (NSString *)pathToSelectedFile;
- (NSString *)nameOfSelectedCategory;
- (NSString *)pathToSelectedCategory;
- (NSString *)nameOfSelectedRootCategory;
- (NSArray *)selectedFiles;
- (NSString *)path;
- (BOOL)setPath:(NSString *)path;
- (void)reloadLastColumn;
// ============================================================================
// ==== Actions
// ============================================================================
- (void)click:(id)sender;
- (void)doubleClick:(id)sender;
- (BOOL)isEditableCategory:(NSString *)category file: (NSString *)title;
// ============================================================================
// ==== Notifications
// ============================================================================
- (void)projectDictDidChange:(NSNotification *)aNotif;
- (NSArray *)selectedFiles;
- (NSString *)nameOfSelectedFile;
- (NSString *)pathOfSelectedFile;
- (void)setBrowser:(NSBrowser *)aBrowser;
- (void)setProject:(PCProject *)aProj;
- (BOOL)setPathForFile:(NSString *)file category:(NSString *)category;
@end
@interface PCBrowserController (ProjectBrowserDelegate)
@interface PCProjectBrowser (ProjectBrowserDelegate)
- (void)browser:(NSBrowser *)sender createRowsForColumn:(int)column inMatrix:(NSMatrix *)matrix;
- (void)browser:(NSBrowser *)sender createRowsForColumn:(int)column
inMatrix:(NSMatrix *)matrix;
@end

453
Library/PCProjectBrowser.m Normal file
View file

@ -0,0 +1,453 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2000-2002 Free Software Foundation
Author: Philippe C.D. Robert <probert@siggraph.org>
This file is part of GNUstep.
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#include "PCDefines.h"
#include "PCFileManager.h"
#include "PCProjectManager.h"
#include "PCProject.h"
#include "PCProjectBrowser.h"
#include "PCProjectEditor.h"
#include "PCLogController.h"
NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification";
@implementation PCProjectBrowser
// ============================================================================
// ==== Intialization & deallocation
// ============================================================================
- (id)initWithProject:(PCProject *)aProject
{
if ((self = [super init]))
{
project = aProject;
browser = [[NSBrowser alloc] initWithFrame:NSMakeRect(-1,251,562,128)];
[browser setRefusesFirstResponder:YES];
[browser setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin];
[browser setTitled:NO];
[browser setMaxVisibleColumns:4];
[browser setSeparatesColumns:NO];
[browser setAllowsMultipleSelection:YES];
[browser setDelegate:self];
[browser setTarget:self];
[browser setAction:@selector(click:)];
[browser setDoubleAction:@selector(doubleClick:)];
[browser loadColumnZero];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(projectDictDidChange:)
name:PCProjectDictDidChangeNotification
object:nil];
}
return self;
}
- (void)dealloc
{
NSLog (@"PCProjectBrowser: dealloc");
[[NSNotificationCenter defaultCenter] removeObserver:self];
RELEASE(browser);
[super dealloc];
}
// ============================================================================
// ==== Accessory methods
// ============================================================================
- (NSView *)view
{
return browser;
}
// Returns nil if multiple files selected
- (NSString *)nameOfSelectedFile
{
NSString *name = nil;
if ([[browser selectedCells] count] == 1)
{
name = [[browser path] lastPathComponent];
if ([name isEqualToString:[self nameOfSelectedCategory]])
{
return nil;
}
}
return name;
}
// Returns nil if multiple files selected
- (NSString *)pathToSelectedFile
{
NSString *name = nil;
NSString *path = nil;
if ([[browser selectedCells] count] == 1)
{
name = [[browser path] lastPathComponent];
if ([name isEqualToString:[self nameOfSelectedCategory]])
{
path = nil;
}
else
{
path = [browser path];
}
}
return path;
}
// Returns nil of multiple categories selected
- (NSString *)nameOfSelectedCategory
{
NSString *name = nil;
NSArray *pathArray = [[browser path] componentsSeparatedByString:@"/"];
PCProject *activeProject = [[project projectManager] activeProject];
NSArray *rootCategories = [activeProject rootCategories];
int i;
if ([rootCategories containsObject:[pathArray lastObject]]
&& [[browser selectedCells] count] > 1)
{
return nil;
}
for (i = [pathArray count] - 1; i >= 0; i--)
{
if ([rootCategories containsObject:[pathArray objectAtIndex:i]])
{
name = [pathArray objectAtIndex:i];
break;
}
}
return name;
}
// Returns nil of multiple categories selected
- (NSString *)pathToSelectedCategory
{
NSString *path = nil;
NSString *selectedCategory = [self nameOfSelectedCategory];
NSMutableArray *bPathArray = nil;
int i;
if (selectedCategory)
{
bPathArray = [NSMutableArray arrayWithArray:[[browser path]
componentsSeparatedByString:@"/"]];
i = [bPathArray count] - 1;
while (![[bPathArray objectAtIndex:i] isEqualToString:selectedCategory])
{
[bPathArray removeObjectAtIndex:i];
i = [bPathArray count] - 1;
}
path = [bPathArray componentsJoinedByString:@"/"];
}
return path;
}
- (NSString *)nameOfSelectedRootCategory
{
NSString *categoryPath = [self pathToSelectedCategory];
NSArray *pathComponents = nil;
if ([categoryPath isEqualToString:@"/"] || [categoryPath isEqualToString:@""])
{
return nil;
}
pathComponents = [categoryPath componentsSeparatedByString:@"/"];
return [pathComponents objectAtIndex:1];
}
- (NSArray *)selectedFiles
{
NSArray *cells = [browser selectedCells];
NSMutableArray *files = [[NSMutableArray alloc] initWithCapacity: 1];
int i;
int count = [cells count];
PCProject *activeProject = [[project projectManager] activeProject];
// Return nil if categories selected
if ([cells count] == 0
|| [[activeProject rootCategories]
containsObject:[[cells objectAtIndex:0] stringValue]])
{
return nil;
}
for (i = 0; i < count; i++)
{
[files addObject: [[cells objectAtIndex: i] stringValue]];
}
return (NSArray *)files;
}
- (NSString *)path
{
return [browser path];
}
- (BOOL)setPath:(NSString *)path
{
int selectedColumn;
NSMatrix *columnMatrix = nil;
BOOL res;
if ([[browser path] isEqualToString: path])
{
return YES;
}
// HACK!!! NSBrowser needs fixing!!!
while ((selectedColumn = [browser selectedColumn]) >= 0)
{
columnMatrix = [browser matrixInColumn:selectedColumn];
[columnMatrix deselectAllCells];
}
// End of HACK
PCLogInfo(self, @"[setPath]: %@", path);
res = [browser setPath:path];
[[NSNotificationCenter defaultCenter]
postNotificationName:PCBrowserDidSetPathNotification
object:self];
return res;
}
- (void)reloadLastColumn
{
int column = [browser lastColumn];
NSString *category = [self nameOfSelectedCategory];
int selectedColumn = [browser selectedColumn];
NSMatrix *colMatrix = [browser matrixInColumn:selectedColumn];
int rowCount = 0, colCount = 0, spCount = 0;
PCProject *activeProject = [[project projectManager] activeProject];
[colMatrix getNumberOfRows:&rowCount columns:&colCount];
spCount = [[[activeProject projectDict] objectForKey:PCSubprojects] count];
if ([category isEqualToString:@"Subprojects"] && rowCount != spCount
&& ![[[browser selectedCell] stringValue] isEqualToString:@"Subprojects"])
{
column = selectedColumn;
}
[browser reloadColumn:column];
[[NSNotificationCenter defaultCenter]
postNotificationName:PCBrowserDidSetPathNotification
object:self];
}
// ============================================================================
// ==== Actions
// ============================================================================
- (void)click:(id)sender
{
NSUserDefaults *ud = nil;
NSString *category = nil;
NSString *fileName = nil;
NSString *filePath = nil;
NSString *key = nil;
PCProject *activeProject = nil;
if (sender != browser)
{
return;
}
if ([[sender selectedCell] isLeaf] && [[self selectedFiles] count] == 1)
{
ud = [NSUserDefaults standardUserDefaults];
category = [self nameOfSelectedCategory];
fileName = [[sender selectedCell] stringValue];
activeProject = [[project projectManager] activeProject];
key = [activeProject keyForCategory:category];
filePath = [activeProject dirForCategoryKey:key];
filePath = [filePath stringByAppendingPathComponent:fileName];
PCLogInfo(self, @"[click] category: %@ filePath: %@",
category, filePath);
if ([activeProject isEditableCategory:category])
{
if (![[ud objectForKey:SeparateEditor] isEqualToString:@"YES"])
{
[[project projectEditor] editorForFile:filePath
categoryPath:[browser path]
windowed:NO];
}
}
}
PCLogStatus(self, @"nameOfSelectedCategory: %@",
[self nameOfSelectedCategory]);
PCLogStatus(self, @"nameOfSelectedFile: %@",
[self nameOfSelectedFile]);
[[NSNotificationCenter defaultCenter]
postNotificationName:PCBrowserDidSetPathNotification
object:self];
}
- (void)doubleClick:(id)sender
{
id selectedCell;
if (sender != browser)
{
return;
}
selectedCell = [sender selectedCell];
if ([selectedCell isLeaf])
{
NSString *category = [self nameOfSelectedCategory];
NSString *fileName = [[sender selectedCell] stringValue];
NSString *filePath = nil;
NSString *key = nil;
PCProject *activeProject = nil;
activeProject = [[project projectManager] activeProject];
key = [activeProject keyForCategory:category];
filePath = [activeProject dirForCategoryKey:key];
filePath = [filePath stringByAppendingPathComponent:fileName];
PCLogInfo(self, @"{doubleClick} filePath: %@", filePath);
if ([activeProject isEditableCategory:category])
{
[[project projectEditor] editorForFile:filePath
categoryPath:[browser path]
windowed:YES];
}
else if ([[NSWorkspace sharedWorkspace] openFile:filePath] == NO)
{
NSRunAlertPanel(@"Attention!",
@"Could not open %@.",
@"OK",nil,nil,filePath);
}
}
else
{
if ([[selectedCell title] isEqualToString:@"Subprojects"])
{
[[project projectManager] addSubproject];
}
else
{
[[project projectManager] addProjectFiles];
}
}
}
// ============================================================================
// ==== Notifications
// ============================================================================
- (void)projectDictDidChange:(NSNotification *)aNotif
{
PCProject *changedProject = nil;
PCProject *activeProject = nil;
if (!browser)
{
return;
}
changedProject = [aNotif object];
activeProject = [[project projectManager] activeProject];
if (changedProject == project || changedProject == activeProject)
{
[self reloadLastColumn];
}
}
@end
@implementation PCProjectBrowser (ProjectBrowserDelegate)
- (void)browser:(NSBrowser *)sender createRowsForColumn:(int)column
inMatrix:(NSMatrix *)matrix
{
NSString *pathToCol = nil;
NSArray *files = nil;
int i = 0;
int count = 0;
if (sender != browser || !matrix || ![matrix isKindOfClass:[NSMatrix class]])
{
return;
}
pathToCol = [sender pathToColumn:column];
files = [project contentAtCategoryPath:pathToCol];
if (files)
{
count = [files count];
}
for (i = 0; i < count; ++i)
{
NSMutableString *categoryPath = nil;
id cell;
categoryPath = [NSMutableString stringWithString:pathToCol];
[matrix insertRow:i];
cell = [matrix cellAtRow:i column:0];
[cell setStringValue:[files objectAtIndex:i]];
if (![categoryPath isEqualToString:@"/"])
{
[categoryPath appendString:@"/"];
}
[categoryPath appendString:[files objectAtIndex:i]];
[cell setLeaf:![project hasChildrenAtCategoryPath:categoryPath]];
}
}
@end

119
Library/PCProjectBuilder.h Normal file
View file

@ -0,0 +1,119 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2000-2002 Free Software Foundation
Author: Philippe C.D. Robert <probert@siggraph.org>
This file is part of GNUstep.
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#ifndef _PCPROJECTBUILDER_H
#define _PCPROJECTBUILDER_H
#include <AppKit/AppKit.h>
#ifndef GNUSTEP_BASE_VERSION
@protocol ProjectComponent;
#else
#include <ProjectCenter/ProjectComponent.h>
#endif
@class PCProject;
@class PCButton;
@interface PCProjectBuilder : NSObject <ProjectComponent>
{
NSBox *componentView;
PCButton *buildButton;
PCButton *cleanButton;
PCButton *installButton;
PCButton *optionsButton;
id buildStatusField;
id targetField;
NSTextView *logOutput;
NSTextView *errorOutput;
NSPopUpButton *popup;
NSPanel *optionsPanel;
NSTextField *buildTargetHostField;
NSTextField *buildTargetArgsField;
NSString *makePath;
PCProject *currentProject;
NSDictionary *currentOptions;
NSString *statusString;
NSMutableString *buildTarget;
NSMutableArray *buildArgs;
SEL postProcess;
NSTask *makeTask;
NSFileHandle *readHandle;
NSFileHandle *errorReadHandle;
BOOL _isBuilding;
BOOL _isCleaning;
}
- (id)initWithProject:(PCProject *)aProject;
- (void)dealloc;
- (NSView *)componentView;
- (void)setTooltips;
// --- Accessory
- (BOOL)isBuilding;
- (BOOL)isCleaning;
- (void)performStartBuild;
- (void)performStartClean;
- (void)performStopBuild;
// --- Actions
- (void)startBuild:(id)sender;
- (BOOL)stopBuild:(id)sender;
- (void)startClean:(id)sender;
- (void)build:(id)sender;
//- (void)buildDidTerminate;
- (void)popupChanged:(id)sender;
- (void)logStdOut:(NSNotification *)aNotif;
- (void)logErrOut:(NSNotification *)aNotif;
- (void)copyPackageTo:(NSString *)path;
@end
@interface PCProjectBuilder (UserInterface)
- (void) _createComponentView;
- (void) _createOptionsPanel;
@end
@interface PCProjectBuilder (BuildLogging)
- (void)logString:(NSString *)string error:(BOOL)yn;
- (void)logString:(NSString *)string error:(BOOL)yn newLine:(BOOL)newLine;
- (void)logData:(NSData *)data error:(BOOL)yn;
@end
#endif

795
Library/PCProjectBuilder.m Normal file
View file

@ -0,0 +1,795 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2000-2002 Free Software Foundation
Author: Philippe C.D. Robert <probert@siggraph.org>
This file is part of GNUstep.
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#include <AppKit/AppKit.h>
#include "PCDefines.h"
#include "PCSplitView.h"
#include "PCButton.h"
#include "PCProjectManager.h"
#include "PCProject.h"
#include "PCProjectBuilder.h"
#include "PCLogController.h"
#ifndef IMAGE
#define IMAGE(X) [NSImage imageNamed: X]
#endif
#ifndef NOTIFICATION_CENTER
#define NOTIFICATION_CENTER [NSNotificationCenter defaultCenter]
#endif
@implementation PCProjectBuilder (UserInterface)
- (void) _createComponentView
{
NSSplitView *split;
NSScrollView *scrollView1;
NSScrollView *scrollView2;
id textField;
componentView = [[NSBox alloc] initWithFrame: NSMakeRect(8,-1,464,322)];
[componentView setTitlePosition: NSNoTitle];
[componentView setBorderType: NSNoBorder];
[componentView setAutoresizingMask: NSViewWidthSizable
| NSViewHeightSizable];
[componentView setContentViewMargins: NSMakeSize (0.0, 0.0)];
/*
* 4 build Buttons
*/
buildButton = [[PCButton alloc] initWithFrame: NSMakeRect(0,271,43,43)];
[buildButton setTitle: @"Build"];
[buildButton setImage: IMAGE(@"Build")];
[buildButton setAlternateImage: IMAGE(@"Stop")];
[buildButton setTarget: self];
[buildButton setAction: @selector(startBuild:)];
[buildButton setAutoresizingMask: (NSViewMaxXMargin | NSViewMinYMargin)];
[buildButton setButtonType: NSToggleButton];
[componentView addSubview: buildButton];
RELEASE (buildButton);
cleanButton = [[PCButton alloc] initWithFrame: NSMakeRect(44,271,43,43)];
[cleanButton setTitle: @"Clean"];
[cleanButton setImage: IMAGE(@"Clean")];
[cleanButton setAlternateImage: IMAGE(@"Stop")];
[cleanButton setTarget: self];
[cleanButton setAction: @selector(startClean:)];
[cleanButton setAutoresizingMask: (NSViewMaxXMargin | NSViewMinYMargin)];
[cleanButton setButtonType: NSToggleButton];
[componentView addSubview: cleanButton];
RELEASE (cleanButton);
installButton = [[PCButton alloc] initWithFrame: NSMakeRect(88,271,43,43)];
[installButton setTitle: @"Install"];
[installButton setImage: IMAGE(@"Install")];
[installButton setAlternateImage: IMAGE(@"Stop")];
[installButton setTarget: self];
[installButton setAction: @selector(startInstall:)];
[installButton setAutoresizingMask: (NSViewMaxXMargin | NSViewMinYMargin)];
[installButton setButtonType: NSToggleButton];
[componentView addSubview: installButton];
RELEASE (installButton);
optionsButton = [[PCButton alloc] initWithFrame: NSMakeRect(132,271,43,43)];
[optionsButton setTitle: @"Options"];
[optionsButton setImage: IMAGE(@"Options")];
[optionsButton setTarget: self];
[optionsButton setAction: @selector(showOptionsPanel:)];
[optionsButton setAutoresizingMask: (NSViewMaxXMargin | NSViewMinYMargin)];
[optionsButton setButtonType: NSMomentaryPushButton];
[componentView addSubview: optionsButton];
RELEASE (optionsButton);
/*
* Error and Log output
*/
scrollView1 = [[NSScrollView alloc]
initWithFrame:NSMakeRect (0, 0, 464, 120)];
[scrollView1 setHasHorizontalScroller:NO];
[scrollView1 setHasVerticalScroller:YES];
[scrollView1 setBorderType: NSBezelBorder];
[scrollView1 setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
errorOutput = [[NSTextView alloc]
initWithFrame: [[scrollView1 contentView] frame]];
[errorOutput setRichText: NO];
[errorOutput setEditable: NO];
[errorOutput setSelectable: YES];
[errorOutput setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
[errorOutput setBackgroundColor: [NSColor colorWithDeviceRed: 0.88
green: 0.76
blue: 0.60
alpha: 1.0]];
[errorOutput setHorizontallyResizable: NO];
[errorOutput setVerticallyResizable: YES];
[errorOutput setMinSize: NSMakeSize (0, 0)];
[errorOutput setMaxSize: NSMakeSize (1E7, 1E7)];
[[errorOutput textContainer] setContainerSize:
NSMakeSize ([errorOutput frame].size.width, 1e7)];
[[errorOutput textContainer] setWidthTracksTextView:YES];
[scrollView1 setDocumentView:errorOutput];
RELEASE(errorOutput);
/*
*/
scrollView2 = [[NSScrollView alloc]
initWithFrame:NSMakeRect (0, 0, 480, 133)];
[scrollView2 setHasHorizontalScroller: NO];
[scrollView2 setHasVerticalScroller: YES];
[scrollView2 setBorderType: NSBezelBorder];
[scrollView2 setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
logOutput = [[NSTextView alloc]
initWithFrame:[[scrollView2 contentView] frame]];
[logOutput setRichText:NO];
[logOutput setEditable:NO];
[logOutput setSelectable:YES];
[logOutput setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
[logOutput setBackgroundColor: [NSColor lightGrayColor]];
[[logOutput textContainer] setWidthTracksTextView:YES];
[[logOutput textContainer] setHeightTracksTextView:YES];
[logOutput setHorizontallyResizable: NO];
[logOutput setVerticallyResizable: YES];
[logOutput setMinSize: NSMakeSize (0, 0)];
[logOutput setMaxSize: NSMakeSize (1E7, 1E7)];
[[logOutput textContainer] setContainerSize:
NSMakeSize ([logOutput frame].size.width, 1e7)];
[[logOutput textContainer] setWidthTracksTextView:YES];
[scrollView2 setDocumentView:logOutput];
RELEASE(logOutput);
split = [[PCSplitView alloc] initWithFrame: NSMakeRect (0, 0, 464, 255)];
[split setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)];
[split addSubview: scrollView1];
RELEASE (scrollView1);
[split addSubview: scrollView2];
RELEASE (scrollView2);
[split adjustSubviews];
[componentView addSubview: split];
RELEASE (split);
/*
* Target
*/
textField = [[NSTextField alloc]
initWithFrame: NSMakeRect (200, 293, 48, 21)];
[textField setAlignment: NSRightTextAlignment];
[textField setBordered: NO];
[textField setBezeled: NO];
[textField setEditable: NO];
[textField setSelectable: NO];
[textField setDrawsBackground: NO];
[textField setStringValue:@"Target:"];
[textField setAutoresizingMask: (NSViewMaxXMargin | NSViewMinYMargin)];
[componentView addSubview: textField];
RELEASE(textField);
/*
* Target message
*/
targetField = [[NSTextField alloc]
initWithFrame:NSMakeRect(251, 293, 220, 21)];
[targetField setAlignment: NSLeftTextAlignment];
[targetField setBordered: NO];
[targetField setEditable: NO];
[targetField setBezeled: NO];
[targetField setSelectable: NO];
[targetField setDrawsBackground: NO];
[targetField setStringValue: @"Default with args ' '"];
[targetField setAutoresizingMask: (NSViewMaxXMargin |
NSViewWidthSizable |
NSViewMinYMargin)];
[componentView addSubview:targetField];
RELEASE (targetField);
/*
* Status
*/
textField = [[NSTextField alloc]
initWithFrame: NSMakeRect (200, 270, 48, 21)];
[textField setAlignment: NSRightTextAlignment];
[textField setBordered: NO];
[textField setSelectable: NO];
[textField setEditable: NO];
[textField setBezeled: NO];
[textField setDrawsBackground: NO];
[textField setStringValue:@"Status:"];
[textField setAutoresizingMask: (NSViewMaxXMargin | NSViewMinYMargin)];
[componentView addSubview:textField];
RELEASE(textField);
/*
* Status message
*/
buildStatusField = [[NSTextField alloc]
initWithFrame: NSMakeRect (251, 270, 220, 21)];
[buildStatusField setAlignment: NSLeftTextAlignment];
[buildStatusField setBordered: NO];
[buildStatusField setEditable: NO];
[buildStatusField setSelectable: NO];
[buildStatusField setBezeled: NO];
[buildStatusField setDrawsBackground: NO];
[buildStatusField setStringValue: @"Waiting..."];
[buildStatusField setAutoresizingMask: (NSViewMaxXMargin |
NSViewWidthSizable |
NSViewMinYMargin)];
[componentView addSubview: buildStatusField];
RELEASE(buildStatusField);
}
- (void) _createOptionsPanel
{
NSView *cView = nil;
NSTextField *textField = nil;
optionsPanel = [[NSPanel alloc]
initWithContentRect: NSMakeRect (100, 100, 300, 120)
styleMask: NSTitledWindowMask | NSClosableWindowMask
backing: NSBackingStoreBuffered
defer: YES];
[optionsPanel setDelegate: self];
[optionsPanel setReleasedWhenClosed: NO];
[optionsPanel setTitle: @"Build Options"];
cView = [optionsPanel contentView];
// Args
textField = [[NSTextField alloc] initWithFrame: NSMakeRect (8,91,60,21)];
[textField setAlignment: NSRightTextAlignment];
[textField setBordered: NO];
[textField setEditable: NO];
[textField setBezeled: NO];
[textField setDrawsBackground: NO];
[textField setStringValue: @"Arguments:"];
[cView addSubview: textField];
RELEASE (textField);
// Args message
buildTargetArgsField = [[NSTextField alloc]
initWithFrame: NSMakeRect (70, 91, 220, 21)];
[buildTargetArgsField setAlignment: NSLeftTextAlignment];
[buildTargetArgsField setBordered: NO];
[buildTargetArgsField setEditable: YES];
[buildTargetArgsField setBezeled: YES];
[buildTargetArgsField setDrawsBackground: YES];
[buildTargetArgsField setStringValue: @""];
[buildTargetArgsField setDelegate: self];
[buildTargetArgsField setTarget: self];
[buildTargetArgsField setAction: @selector (setArguments:)];
[cView addSubview: buildTargetArgsField];
// RELEASE (buildTargetArgsField);
// Host
textField = [[NSTextField alloc] initWithFrame: NSMakeRect (8,67,60,21)];
[textField setAlignment: NSRightTextAlignment];
[textField setBordered: NO];
[textField setEditable: NO];
[textField setBezeled: NO];
[textField setDrawsBackground: NO];
[textField setStringValue: @"Host:"];
[cView addSubview: textField];
RELEASE (textField);
// Host message
buildTargetHostField = [[NSTextField alloc]
initWithFrame: NSMakeRect (70, 67, 220, 21)];
[buildTargetHostField setAlignment: NSLeftTextAlignment];
[buildTargetHostField setBordered: NO];
[buildTargetHostField setEditable: YES];
[buildTargetHostField setBezeled: YES];
[buildTargetHostField setDrawsBackground: YES];
[buildTargetHostField setStringValue: @"localhost"];
[buildTargetHostField setDelegate: self];
[buildTargetHostField setTarget: self];
[buildTargetHostField setAction: @selector (setHost:)];
[cView addSubview: buildTargetHostField];
// RELEASE (buildTargetArgsField);
// Target
textField = [[NSTextField alloc]
initWithFrame: NSMakeRect (8, 40, 60, 21)];
[textField setAlignment: NSRightTextAlignment];
[textField setBordered: NO];
[textField setBezeled: NO];
[textField setEditable: NO];
[textField setSelectable: NO];
[textField setDrawsBackground: NO];
[textField setStringValue: @"Target:"];
[textField setAutoresizingMask: (NSViewMaxXMargin | NSViewMinYMargin)];
[cView addSubview: textField];
RELEASE(textField);
// Target popup
popup = [[NSPopUpButton alloc]
initWithFrame: NSMakeRect (70, 40, 220, 21)];
[popup addItemWithTitle: @"Default"];
[popup addItemWithTitle: @"Debug"];
[popup addItemWithTitle: @"Profile"];
[popup addItemWithTitle: @"Tarball"];
[popup addItemWithTitle: @"RPM"];
[popup setTarget: self];
[popup setAction: @selector (popupChanged:)];
[popup setAutoresizingMask: (NSViewMaxXMargin | NSViewMinYMargin)];
[cView addSubview: popup];
RELEASE (popup);
}
@end
@implementation PCProjectBuilder
- (id)initWithProject:(PCProject *)aProject
{
NSAssert(aProject, @"No project specified!");
PCLogInfo(self, @"initWithProject %@", [aProject projectName]);
if ((self = [super init]))
{
currentProject = aProject;
makePath = [[aProject projectDict] objectForKey: PCBuildTool];
if ([makePath isEqualToString: @""])
{
makePath = [NSString stringWithString: @"/usr/bin/make"];
}
RETAIN(makePath);
buildTarget = [[NSMutableString alloc] initWithString: @"Default"];
buildArgs = [[NSMutableArray array] retain];
postProcess = NULL;
makeTask = nil;
_isBuilding = NO;
_isCleaning = NO;
}
return self;
}
- (void)dealloc
{
NSLog (@"PCProjectBuilder: dealloc");
[buildTarget release];
[buildArgs release];
[makePath release];
PCLogInfo(self, @"componentView RC: %i", [componentView retainCount]);
PCLogInfo(self, @"RC: %i", [self retainCount]);
[componentView release];
[super dealloc];
}
- (NSView *)componentView
{
if (!componentView)
{
[self _createComponentView];
}
return componentView;
}
- (void)setTooltips
{
[buildButton setShowTooltip:NO];
[cleanButton setShowTooltip:NO];
[installButton setShowTooltip:NO];
[optionsButton setShowTooltip:NO];
}
// --- Accessory
- (BOOL)isBuilding
{
return _isBuilding;
}
- (BOOL)isCleaning
{
return _isCleaning;
}
- (void)performStartBuild
{
if (!_isBuilding && !_isCleaning)
{
[buildButton performClick:self];
}
}
- (void)performStartClean
{
if (!_isCleaning && !_isBuilding)
{
[cleanButton performClick:self];
}
}
- (void)performStopBuild
{
if (_isBuilding)
{
[buildButton performClick:self];
}
else if (_isCleaning)
{
[cleanButton performClick:self];
}
}
// --- GUI Actions
- (void)startBuild:(id)sender
{
NSString *tFString = [targetField stringValue];
NSArray *tFArray = [tFString componentsSeparatedByString: @" "];
if ([self stopBuild:self] == YES)
{// We've just stopped build process
return;
}
[buildTarget setString: [tFArray objectAtIndex: 0]];
// Set build arguments
if ([buildTarget isEqualToString: @"Debug"])
{
[buildArgs addObject: @"debug=yes"];
}
else if ([buildTarget isEqualToString: @"Profile"])
{
[buildArgs addObject: @"profile=yes"];
[buildArgs addObject: @"static=yes"];
}
else if ([buildTarget isEqualToString: @"Tarball"])
{
[buildArgs addObject: @"dist"];
}
else if ([buildTarget isEqualToString: @"RPM"])
{
[buildArgs addObject: @"rpm"];
postProcess = @selector (copyPackageTo:);
}
statusString = [NSString stringWithString: @"Building..."];
[buildTarget setString: @"Build"];
[cleanButton setEnabled:NO];
[installButton setEnabled:NO];
[self build: self];
_isBuilding = YES;
}
- (BOOL)stopBuild:(id)sender
{
// [makeTask isRunning] doesn't work here.
// "waitpid 7045, result -1, error No child processes" is printed.
if (makeTask)
{
PCLogStatus(self, @"task will terminate");
[makeTask terminate];
return YES;
}
return NO;
}
- (void)startClean:(id)sender
{
if ([[[[NSUserDefaults standardUserDefaults] dictionaryRepresentation]
objectForKey: PromptOnClean] isEqualToString: @"YES"])
{
if (NSRunAlertPanel(@"Clean Project?",
@"Do you really want to clean project '%@'?",
@"Yes",
@"No",
nil,
[currentProject projectName])
== NSAlertAlternateReturn)
{
[cleanButton setState: NSOffState];
return;
}
}
[buildTarget setString: @"Clean"];
statusString = [NSString stringWithString: @"Cleaning..."];
[buildArgs addObject: @"distclean"];
[buildButton setEnabled:NO];
[installButton setEnabled:NO];
[self build: self];
_isCleaning = YES;
}
- (void)startInstall:(id)sender
{
[buildTarget setString: @"Install"];
statusString = [NSString stringWithString: @"Installing..."];
[buildArgs addObject: @"install"];
[buildButton setEnabled:NO];
[cleanButton setEnabled:NO];
[self build: self];
}
- (void)showOptionsPanel:(id)sender
{
if (!optionsPanel)
{
[self _createOptionsPanel];
}
[optionsPanel orderFront: nil];
}
// --- Actions
- (void)build:(id)sender
{
NSPipe *logPipe;
NSPipe *errorPipe;
NSDictionary *env = [[NSProcessInfo processInfo] environment];
// Support build options!!!
//NSDictionary *optionDict = [currentProject buildOptions];
// Checking prerequisites
if ([currentProject isProjectChanged])
{
if (NSRunAlertPanel(@"Project Changed!",
@"Should it be saved first?",
@"Yes",@"No",nil) == NSAlertDefaultReturn)
{
[currentProject save];
}
}
else
{
// Synchronize PC.project and generated files just for case
[currentProject save];
}
if( [buildTarget isEqualToString: @"RPM"]
&& [env objectForKey:@"RPM_TOPDIR"] == nil )
{
NSRunAlertPanel(@"Attention!",
@"First set the environment variable 'RPM_TOPDIR'!",
@"OK",nil,nil);
return;
}
// Prepearing to building
logPipe = [NSPipe pipe];
readHandle = [logPipe fileHandleForReading];
[readHandle waitForDataInBackgroundAndNotify];
[NOTIFICATION_CENTER addObserver: self
selector: @selector (logStdOut:)
name: NSFileHandleDataAvailableNotification
object: readHandle];
errorPipe = [NSPipe pipe];
errorReadHandle = [errorPipe fileHandleForReading];
[errorReadHandle waitForDataInBackgroundAndNotify];
[NOTIFICATION_CENTER addObserver: self
selector: @selector (logErrOut:)
name: NSFileHandleDataAvailableNotification
object: errorReadHandle];
[buildStatusField setStringValue: statusString];
// Run make task
[logOutput setString: @""];
[errorOutput setString: @""];
[NOTIFICATION_CENTER addObserver: self
selector: @selector (buildDidTerminate:)
name: NSTaskDidTerminateNotification
object: nil];
makeTask = [[NSTask alloc] init];
[makeTask setArguments: buildArgs];
[makeTask setCurrentDirectoryPath: [currentProject projectPath]];
[makeTask setLaunchPath: makePath];
[makeTask setStandardOutput: logPipe];
[makeTask setStandardError: errorPipe];
[makeTask launch];
}
- (void)buildDidTerminate:(NSNotification *)aNotif
{
int status;
if ([aNotif object] != makeTask)
{
return;
}
[NOTIFICATION_CENTER removeObserver:self];
status = [makeTask terminationStatus];
if (status == 0)
{
[self logString:
[NSString stringWithFormat: @"=== %@ succeeded!", buildTarget]
error: NO newLine: NO];
[buildStatusField setStringValue:
[NSString stringWithFormat:
@"%@ - %@ succeeded...", [currentProject projectName], buildTarget]];
}
else
{
[self logString:
[NSString stringWithFormat: @"=== %@ terminated!", buildTarget]
error: NO newLine: NO];
[buildStatusField setStringValue:
[NSString stringWithFormat:
@"%@ - %@ terminated...", [currentProject projectName], buildTarget]];
}
// Rstore buttons state
if ([buildTarget isEqualToString: @"Build"])
{
[buildButton setState: NSOffState];
[cleanButton setEnabled: YES];
[installButton setEnabled: YES];
}
else if ([buildTarget isEqualToString: @"Clean"])
{
[cleanButton setState: NSOffState];
[buildButton setEnabled: YES];
[installButton setEnabled: YES];
}
else if ([buildTarget isEqualToString: @"Install"])
{
[installButton setState: NSOffState];
[buildButton setEnabled: YES];
[cleanButton setEnabled: YES];
}
[buildArgs removeAllObjects];
[buildTarget setString: @"Default"];
RELEASE(makeTask);
makeTask = nil;
// Run post process if configured
if (status && postProcess)
{
[self performSelector: postProcess];
postProcess = NULL;
}
_isBuilding = NO;
_isCleaning = NO;
}
- (void)popupChanged:(id)sender
{
NSString *target = [targetField stringValue];
target = [NSString stringWithFormat:
@"%@ with args ' %@ '",
[popup titleOfSelectedItem],
[buildTargetArgsField stringValue]];
[targetField setStringValue: target];
}
- (void)logStdOut:(NSNotification *)aNotif
{
NSData *data;
if ((data = [readHandle availableData]))
{
[self logData: data error: NO];
}
[readHandle waitForDataInBackgroundAndNotifyForModes: nil];
}
- (void)logErrOut:(NSNotification *)aNotif
{
NSData *data;
if ((data = [errorReadHandle availableData]))
{
[self logData:data error:YES];
}
[errorReadHandle waitForDataInBackgroundAndNotifyForModes:nil];
}
- (void)copyPackageTo:(NSString *)path
{
NSString *source = nil;
NSString *dest = nil;
NSString *rpm = nil;
NSString *srcrpm = nil;
// Copy the rpm files to the source directory
if (source)
{
[[NSFileManager defaultManager] copyPath:srcrpm toPath:dest handler:nil];
[[NSFileManager defaultManager] copyPath:rpm toPath:dest handler:nil];
}
}
@end
@implementation PCProjectBuilder (BuildLogging)
- (void)logString: (NSString *)string
error: (BOOL)yn
{
[self logString: string error: yn newLine: NO];
}
- (void)logString: (NSString *)str
error: (BOOL)yn
newLine: (BOOL)newLine
{
NSTextView *out = (yn) ? errorOutput : logOutput;
[out replaceCharactersInRange:
NSMakeRange ([[out string] length],0) withString: str];
if (newLine)
{
[out replaceCharactersInRange:
NSMakeRange ([[out string] length], 0) withString: @"\n"];
}
else
{
[out replaceCharactersInRange:
NSMakeRange ([[out string] length], 0) withString: @" "];
}
[out scrollRangeToVisible: NSMakeRange([[out string] length], 0)];
[out setNeedsDisplay: YES];
}
- (void)logData: (NSData *)data
error: (BOOL)yn
{
NSString *s = [[NSString alloc] initWithData: data
encoding: [NSString defaultCStringEncoding]];
[self logString: s error: yn newLine: NO];
RELEASE(s);
}
@end

111
Library/PCProjectEditor.h Normal file
View file

@ -0,0 +1,111 @@
/*
* 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_
#include <Foundation/Foundation.h>
#include "PCProject.h"
@class PCProject;
@class PCEditor;
@class PCEditorView;
@class NSBox;
@class NSView;
@class NSScrollView;
#ifndef GNUSTEP_BASE_VERSION
@protocol ProjectComponent;
#else
#include <ProjectCenter/ProjectComponent.h>
#endif
@interface PCProjectEditor : NSObject
{
PCProject *project;
NSBox *componentView;
NSScrollView *scrollView;
NSMutableDictionary *editorsDict;
PCEditor *activeEditor;
}
// ===========================================================================
// ==== Class Methods
// ===========================================================================
+ (PCEditor *)openFileInEditor:(NSString *)path;
// ===========================================================================
// ==== Initialisation
// ===========================================================================
- (id)initWithProject:(PCProject *)aProject;
- (void)dealloc;
- (NSView *)componentView;
- (PCProject *)project;
// ===========================================================================
// ==== Project and Editor handling
// ===========================================================================
- (PCEditor *)editorForFile:(NSString *)path
categoryPath:(NSString *)categoryPath
windowed:(BOOL)yn;
- (void)orderFrontEditorForFile:(NSString *)path;
- (PCEditor *)activeEditor;
- (void)setActiveEditor:(PCEditor *)anEditor;
- (NSArray *)allEditors;
- (void)closeActiveEditor:(id)sender;
- (void)closeEditorForFile:(NSString *)file;
- (BOOL)closeAllEditors;
// ===========================================================================
// ==== File handling
// ===========================================================================
- (BOOL)saveEditedFiles:(NSArray *)files;
- (BOOL)saveAllFiles;
- (BOOL)saveFile;
- (BOOL)saveFileAs:(NSString *)file;
- (BOOL)saveFileTo:(NSString *)file;
- (BOOL)revertFileToSaved;
// ===========================================================================
// ==== Delegate
// ===========================================================================
- (void)editorDidClose:(id)sender;
- (void)editorDidBecomeActive:(NSNotification *)aNotif;
- (void)editorDidResignActive:(NSNotification *)aNotif;
@end
extern NSString *PCEditorWillOpenNotification;
extern NSString *PCEditorDidOpenNotification;
extern NSString *PCEditorWillCloseNotification;
extern NSString *PCEditorDidCloseNotification;
extern NSString *PCEditorDidBecomeActiveNotification;
extern NSString *PCEditorDidResignActiveNotification;
/*extern NSString *PCEditorDidChangeNotification;
extern NSString *PCEditorWillSaveNotification;
extern NSString *PCEditorDidSaveNotification;
extern NSString *PCEditorSaveDidFailNotification;
extern NSString *PCEditorWillRevertNotification;
extern NSString *PCEditorDidRevertNotification;
extern NSString *PCEditorDeletedNotification;
extern NSString *PCEditorRenamedNotification;*/
#endif

509
Library/PCProjectEditor.m Normal file
View file

@ -0,0 +1,509 @@
/*
* PCProjectEditor.m created by probert on 2002-02-10 09:27:09 +0000
*
* Project ProjectCenter
*
* Created with ProjectCenter - http://www.gnustep.org
*
* $Id$
*/
#include "PCDefines.h"
#include "PCProjectWindow.h"
#include "PCProjectBrowser.h"
#include "PCProjectEditor.h"
#include "PCEditor.h"
#include "PCEditorView.h"
#include "ProjectComponent.h"
#include "PCLogController.h"
NSString *PCEditorDidOpenNotification =
@"PCEditorDidOpenNotification";
NSString *PCEditorDidCloseNotification =
@"PCEditorDidCloseNotification";
NSString *PCEditorDidBecomeActiveNotification =
@"PCEditorDidBecomeActiveNotification";
NSString *PCEditorDidResignActiveNotification =
@"PCEditorDidResignActiveNotification";
@interface PCProjectEditor (CreateUI)
- (void) _createComponentView;
@end
@implementation PCProjectEditor (CreateUI)
- (void) _createComponentView
{
NSRect frame;
NSTextView *textView;
frame = NSMakeRect(0,0,562,248);
componentView = [[NSBox alloc] initWithFrame:frame];
[componentView setTitlePosition: NSNoTitle];
[componentView setBorderType: NSNoBorder];
[componentView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
[componentView setContentViewMargins: NSMakeSize(0.0,0.0)];
frame = NSMakeRect (0, 0, 562, 40);
scrollView = [[NSScrollView alloc] initWithFrame:frame];
[scrollView setHasHorizontalScroller: NO];
[scrollView setHasVerticalScroller: YES];
[scrollView setBorderType: NSBezelBorder];
[scrollView setAutoresizingMask:(NSViewWidthSizable|NSViewHeightSizable)];
// This is a placeholder!
frame = [[scrollView contentView] frame];
textView = [[NSTextView alloc] initWithFrame:frame];
[textView setMinSize: NSMakeSize (0, 0)];
[textView setMaxSize: NSMakeSize(1e7, 1e7)];
[textView setRichText: NO];
[textView setEditable: NO];
[textView setSelectable: YES];
[textView setVerticallyResizable: YES];
[textView setHorizontallyResizable: NO];
[textView setAutoresizingMask:(NSViewWidthSizable|NSViewHeightSizable)];
[[textView textContainer] setWidthTracksTextView: YES];
[scrollView setDocumentView: textView];
RELEASE(textView);
frame.size = NSMakeSize([scrollView contentSize].width,1e7);
[[textView textContainer] setContainerSize:frame.size];
[componentView setContentView:scrollView];
// RELEASE(scrollView);
[componentView sizeToFit];
}
@end
@implementation PCProjectEditor
// ===========================================================================
// ==== Class Methods
// ===========================================================================
+ (PCEditor *)openFileInEditor:(NSString *)path
{
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
NSString *editor = [ud objectForKey:Editor];
if (![editor isEqualToString:@"ProjectCenter"])
{
// NSTask *editorTask;
NSArray *ea = [editor componentsSeparatedByString:@" "];
// NSMutableArray *args = [NSMutableArray arrayWithArray:ea];
NSString *app = [ea objectAtIndex: 0];
if ([[app pathExtension] isEqualToString:@"app"])
{
BOOL ret = [[NSWorkspace sharedWorkspace] openFile:path
withApplication:app];
if (ret == NO)
{
PCLogError(self, @"Could not open %@ using %@", path, app);
}
return nil;
}
editor = [[PCEditor alloc] initExternalEditor:editor
withPath:path
projectEditor:self];
/* editorTask = [[NSTask alloc] init];
[editorTask setLaunchPath:app];
[args removeObjectAtIndex:0];
[args addObject:path];
[editorTask setArguments:args];
AUTORELEASE(editorTask);
[editorTask launch];*/
}
else
{
PCEditor *editor;
editor = [[PCEditor alloc] initWithPath:path
categoryPath:nil
projectEditor:self];
[editor setWindowed:YES];
[editor show];
return editor;
}
return nil;
}
// ===========================================================================
// ==== Initialisation
// ===========================================================================
- (id)initWithProject: (PCProject *)aProject
{
NSAssert(aProject, @"No project specified!");
if ((self = [super init]))
{
PCLogStatus(self, @"[init]");
project = aProject;
componentView = nil;
editorsDict = [[NSMutableDictionary alloc] init];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(editorDidClose:)
name:PCEditorDidCloseNotification
object:nil];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(editorDidBecomeActive:)
name:PCEditorDidBecomeActiveNotification
object:nil];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(editorDidResignActive:)
name:PCEditorDidResignActiveNotification
object:nil];
}
return self;
}
- (void)dealloc
{
NSLog (@"PCProjectEditor: dealloc");
[[NSNotificationCenter defaultCenter] removeObserver:self];
if (componentView)
{
RELEASE(componentView);
}
[self closeAllEditors];
RELEASE(editorsDict);
[super dealloc];
}
- (NSView *)componentView
{
if (componentView == nil)
{
[self _createComponentView];
}
return componentView;
}
- (PCProject *)project
{
return project;
}
// ===========================================================================
// ==== Project and Editor handling
// ===========================================================================
- (PCEditor *)editorForFile:(NSString *)path
categoryPath:(NSString *)categoryPath
windowed:(BOOL)yn
{
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
NSString *ed = [ud objectForKey:Editor];
PCEditor *editor;
if (![ed isEqualToString:@"ProjectCenter"])
{
editor = [[PCEditor alloc] initExternalEditor:ed
withPath:path
projectEditor:self];
return editor;
}
if (!(editor = [editorsDict objectForKey:path]))
{
editor = [[PCEditor alloc] initWithPath:path
categoryPath:categoryPath
projectEditor:self];
[componentView setContentView:[editor componentView]];
[[project projectWindow] makeFirstResponder:[editor editorView]];
[editorsDict setObject:editor forKey:path];
RELEASE(editor);
}
[editor setWindowed:yn];
if (yn)
{
[editor show];
}
return editor;
}
- (void)orderFrontEditorForFile:(NSString *)path
{
PCEditor *editor = [editorsDict objectForKey:path];
NSLog(@"PCProjectEditor: orderFrontEditorForFile");
if ([editor isWindowed])
{
[editor show];
}
else
{
[componentView setContentView:[editor componentView]];
[[project projectWindow] makeFirstResponder:[editor editorView]];
}
}
- (void)setActiveEditor:(PCEditor *)anEditor
{
if (anEditor != activeEditor)
{
activeEditor = anEditor;
}
}
- (PCEditor *)activeEditor
{
return activeEditor;
}
- (NSArray *)allEditors
{
return [editorsDict allValues];
}
- (void)closeActiveEditor:(id)sender
{
[[self activeEditor] closeFile:self save:YES];
}
- (void)closeEditorForFile:(NSString *)file
{
PCEditor *editor;
editor = [editorsDict objectForKey:file];
[editor closeFile:self save:YES];
[editorsDict removeObjectForKey:file];
}
- (BOOL)closeAllEditors
{
NSEnumerator *enumerator = [editorsDict keyEnumerator];
PCEditor *editor;
NSString *key;
NSMutableArray *editedFiles = [[NSMutableArray alloc] init];
while ((key = [enumerator nextObject]))
{
editor = [editorsDict objectForKey:key];
if ([editor isEdited])
{
[editedFiles addObject:[key lastPathComponent]];
}
else
{
[editor closeFile:self save:YES];
}
}
// Order panel with list of changed files
if ([editedFiles count])
{
if ([self saveEditedFiles:(NSArray *)editedFiles] == NO)
{
return NO;
}
}
[editorsDict removeAllObjects];
return YES;
}
// ===========================================================================
// ==== File handling
// ===========================================================================
- (BOOL)saveEditedFiles:(NSArray *)files
{
int ret;
ret = NSRunAlertPanel(@"Alert",
@"Project has modified files\n%@",
@"Save and Close",@"Close",@"Don't close",
files);
switch (ret)
{
case NSAlertDefaultReturn:
if ([self saveAllFiles] == NO)
{
return NO;
}
break;
case NSAlertAlternateReturn:
// Close files without saving
break;
case NSAlertOtherReturn:
return NO;
break;
}
return YES;
}
- (BOOL)saveAllFiles
{
NSEnumerator *enumerator = [editorsDict keyEnumerator];
PCEditor *editor;
NSString *key;
BOOL ret = YES;
while ((key = [enumerator nextObject]))
{
editor = [editorsDict objectForKey:key];
if ([editor saveFileIfNeeded] == NO)
{
ret = NO;
}
}
return ret;
}
- (BOOL)saveFile
{
PCEditor *editor = [self activeEditor];
if (editor != nil)
{
return [editor saveFileIfNeeded];
}
return NO;
}
- (BOOL)saveFileAs:(NSString *)file
{
PCEditor *editor = [self activeEditor];
if (editor != nil)
{
BOOL res;
BOOL iw = [editor isWindowed];
NSString *categoryPath = [editor categoryPath];
res = [editor saveFileTo:file];
[editor closeFile:self save:NO];
[self editorForFile:file categoryPath:categoryPath windowed:iw];
return res;
}
return NO;
}
- (BOOL)saveFileTo:(NSString *)file
{
PCEditor *editor = [self activeEditor];
if (editor != nil)
{
return [editor saveFileTo:file];
}
return NO;
}
- (BOOL)revertFileToSaved
{
PCEditor *editor = [self activeEditor];
if (editor != nil)
{
return [editor revertFileToSaved];
}
return NO;
}
// ===========================================================================
// ==== Notifications
// ===========================================================================
- (void)editorDidClose:(NSNotification *)aNotif
{
PCEditor *editor = [aNotif object];
// It is not our editor
if ([editorsDict objectForKey:[editor path]] != editor)
{
return;
}
[editorsDict removeObjectForKey:[editor path]];
if ([editorsDict count])
{
NSString *lastEditorKey = [[editorsDict allKeys] lastObject];
PCEditor *lastEditor = [editorsDict objectForKey:lastEditorKey];
lastEditorKey = [[editorsDict allKeys] lastObject];
[componentView setContentView:[lastEditor componentView]];
// [[project projectWindow] makeFirstResponder:[lastEditor editorView]];
[self setActiveEditor:lastEditor];
}
else
{
// [[project projectWindow] makeFirstResponder:scrollView];
[componentView setContentView:scrollView];
[self setActiveEditor:nil];
}
}
- (void)editorDidBecomeActive:(NSNotification *)aNotif
{
PCEditor *editor = [aNotif object];
NSString *categoryPath = nil;
NSLog(@"PCPE: editorDidBecomeActive: %@", [editor path]);
if ([editorsDict objectForKey:[editor path]] != editor
|| activeEditor == editor)
{
return;
}
categoryPath = [editor categoryPath];
[self setActiveEditor:editor];
if (categoryPath)
{
PCLogInfo(self, @"set browser path: %@", categoryPath);
[[project projectBrowser] setPath:categoryPath];
}
}
- (void)editorDidResignActive:(NSNotification *)aNotif
{
[self setActiveEditor:nil];
}
@end

View file

@ -0,0 +1,159 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2000-2002 Free Software Foundation
Author: Philippe C.D. Robert <probert@siggraph.org>
This file is part of GNUstep.
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#ifndef _PCProjectInspector_h_
#define _PCProjectInspector_h_
@class PCProjectManager;
@class PCProjectBrowser;
@interface PCFileNameField : NSTextField
{
}
- (void)setEditableField:(BOOL)yn;
- (BOOL)textShouldSetEditable;
@end
@interface PCProjectInspector : NSObject
{
PCProjectManager *projectManager;
PCProject *project;
NSDictionary *projectDict;
IBOutlet NSPanel *inspectorPanel;
IBOutlet NSBox *contentView;
IBOutlet NSPopUpButton *inspectorPopup;
IBOutlet NSBox *inspectorView;
// Build Attributes
IBOutlet NSBox *buildAttributesView;
IBOutlet NSTextField *projectNameLabel;
IBOutlet NSPopUpButton *searchOrderPopup;
IBOutlet NSScrollView *searchOrderScroll;
NSTableView *searchOrderList;
NSTableColumn *searchOrderColumn;
NSMutableArray *searchItems;
NSArray *searchHeaders;
NSArray *searchLibs;
IBOutlet NSTextField *searchOrderTF;
IBOutlet NSButton *searchOrderSet;
IBOutlet NSButton *searchOrderRemove;
IBOutlet NSButton *searchOrderAdd;
IBOutlet NSTextField *cppOptField;
IBOutlet NSTextField *objcOptField;
IBOutlet NSTextField *cOptField;
IBOutlet NSTextField *ldOptField;
IBOutlet NSTextField *installPathField;
IBOutlet NSTextField *toolField;
// Project Attributes
// Suuplied by concrete project
NSView *projectAttributesView;
// Project Description
IBOutlet NSBox *projectDescriptionView;
IBOutlet NSTextField *descriptionField;
IBOutlet NSTextField *releaseField;
IBOutlet NSTextField *licenseField;
IBOutlet NSTextField *licDescriptionField;
IBOutlet NSTextField *urlField;
NSTableView *authorsList;
NSTableColumn *authorsColumn;
IBOutlet NSScrollView *authorsScroll;
NSMutableArray *authorsItems;
IBOutlet NSButton *authorAdd;
IBOutlet NSButton *authorRemove;
IBOutlet NSButton *authorUp;
IBOutlet NSButton *authorDown;
// File Attributes
IBOutlet NSBox *fileAttributesView;
IBOutlet NSImageView *fileIconView;
IBOutlet PCFileNameField *fileNameField;
NSString *fileName;
}
// ============================================================================
// ==== Intialization & deallocation
// ============================================================================
- (id)initWithProjectManager:(PCProjectManager *)manager;
- (void)close;
- (void)dealloc;
// ============================================================================
// ==== Panel and contents
// ============================================================================
- (BOOL)loadPanel;
- (NSPanel *)panel;
- (NSView *)contentView;
// ============================================================================
// ==== Actions
// ============================================================================
- (void)inspectorPopupDidChange:(id)sender;
- (void)changeCommonProjectEntry:(id)sender;
- (void)selectSectionWithTitle:(NSString *)sectionTitle;
// ============================================================================
// ==== Notifications
// ============================================================================
- (void)activeProjectDidChange:(NSNotification *)aNotif;
- (void)updateValues:(NSNotification *)aNotif;
// ============================================================================
// ==== Build Attributes
// ============================================================================
- (void)createBuildAttributes;
// ----------------------------------------------------------------------------
// --- Search Order
// ----------------------------------------------------------------------------
- (void)searchOrderPopupDidChange:(id)sender;
- (void)searchOrderDoubleClick:(id)sender;
- (void)searchOrderClick:(id)sender;
- (void)setSearchOrderButtonsState;
- (void)setSearchOrder:(id)sender;
- (void)removeSearchOrder:(id)sender;
- (void)addSearchOrder:(id)sender;
- (void)syncSearchOrder;
// ============================================================================
// ==== Project Description
// ============================================================================
- (void)createProjectDescription;
// ============================================================================
// ==== File Attributes
// ============================================================================
- (void)createFileAttributes;
- (void)beginFileRename;
- (void)browserDidSetPath:(NSNotification *)aNotif;
- (void)setFANameAndIcon:(PCProjectBrowser *)browser;
@end
#endif

View file

@ -0,0 +1,804 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2000-2002 Free Software Foundation
Author: Philippe C.D. Robert <probert@siggraph.org>
This file is part of GNUstep.
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#include "PCDefines.h"
#include "PCProjectManager.h"
#include "PCProject.h"
#include "PCProjectBrowser.h"
#include "PCProjectWindow.h"
#include "PCProjectInspector.h"
#include "PCLogController.h"
@implementation PCFileNameField
- (void)setEditableField:(BOOL)yn
{
NSRect frame = [self frame];
if ([self textShouldSetEditable] == NO)
{
return;
}
if (yn == YES)
{
frame.size.width += 4;
frame.origin.x -= 4;
[self setFrame:frame];
[self setBordered:YES];
[self setBackgroundColor:[NSColor whiteColor]];
[self setEditable:YES];
[self setNeedsDisplay:YES];
[[self superview] setNeedsDisplay:YES];
}
else
{
frame.size.width -= 4;
frame.origin.x += 4;
[self setFrame:frame];
[self setBackgroundColor:[NSColor lightGrayColor]];
[self setBordered:NO];
[self setEditable:NO];
[self setNeedsDisplay:YES];
[[self superview] setNeedsDisplay:YES];
}
}
- (void)mouseDown:(NSEvent *)theEvent
{
[self setEditableField:YES];
[super mouseDown:theEvent];
}
- (BOOL)textShouldSetEditable
{
NSString *text = [self stringValue];
if ([text isEqualToString:@"No files selected"]
|| [text isEqualToString:@"Multiple files selected"])
{
return NO;
}
return YES;
}
- (void)textDidEndEditing:(NSNotification *)aNotification
{
[self setEditableField:NO];
[super textDidEndEditing:aNotification];
}
@end
@implementation PCProjectInspector
// ============================================================================
// ==== Intialization & deallocation
// ============================================================================
- (id)initWithProjectManager:(PCProjectManager *)manager
{
projectManager = manager;
[self loadPanel];
// Track project switching
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(activeProjectDidChange:)
name:PCActiveProjectDidChangeNotification
object:nil];
[self inspectorPopupDidChange:inspectorPopup];
return self;
}
- (void)close
{
[inspectorPanel performClose:self];
}
- (void)dealloc
{
NSLog (@"PCProjectInspector: dealloc");
[[NSNotificationCenter defaultCenter] removeObserver:self];
RELEASE(buildAttributesView);
RELEASE(projectAttributesView);
RELEASE(projectDescriptionView);
RELEASE(fileAttributesView);
RELEASE(inspectorPanel);
RELEASE(fileName);
[super dealloc];
}
// ============================================================================
// ==== Panel & contents
// ============================================================================
- (BOOL)loadPanel
{
if ([NSBundle loadNibNamed:@"ProjectInspector" owner:self] == NO)
{
PCLogError(self, @"error loading NIB file!");
return NO;
}
// Panel
[inspectorPanel setFrameAutosaveName:@"ProjectInspector"];
[inspectorPanel setFrameUsingName:@"ProjectInspector"];
// PopUp
[inspectorPopup removeAllItems];
[inspectorPopup addItemWithTitle:@"Build Attributes"];
[inspectorPopup addItemWithTitle:@"Project Attributes"];
[inspectorPopup addItemWithTitle:@"Project Description"];
[inspectorPopup addItemWithTitle:@"File Attributes"];
[inspectorPopup selectItemAtIndex:0];
// Build Attributes
[self createBuildAttributes];
// Project Description
[self createProjectDescription];
// File Attributes
[self createFileAttributes];
[self activeProjectDidChange:nil];
return YES;
}
- (NSPanel *)panel
{
if (!inspectorPanel && ([self loadPanel] == NO))
{
return nil;
}
return inspectorPanel;
}
- (NSView *)contentView
{
if (!contentView && ([self loadPanel] == NO))
{
return nil;
}
return contentView;
}
// ============================================================================
// ==== Actions
// ============================================================================
- (void)inspectorPopupDidChange:(id)sender
{
switch([sender indexOfSelectedItem])
{
case 0:
[inspectorView setContentView:buildAttributesView];
break;
case 1:
[inspectorView setContentView: projectAttributesView];
break;
case 2:
[inspectorView setContentView: projectDescriptionView];
break;
case 3:
[inspectorView setContentView:fileAttributesView];
break;
}
[inspectorView display];
}
- (void)changeCommonProjectEntry:(id)sender
{
NSString *newEntry = [sender stringValue];
// Build Atributes
if (sender == installPathField
&& ![[[project projectDict] objectForKey:PCInstallDir] isEqualToString:newEntry])
{
[project setProjectDictObject:newEntry forKey:PCInstallDir];
}
else if (sender == toolField)
{
[project setProjectDictObject:newEntry forKey:PCBuildTool];
if (![[NSFileManager defaultManager] isExecutableFileAtPath:newEntry])
{
NSRunAlertPanel(@"Build Tool Error!",
@"No valid executable found at '%@'!",
@"OK",nil,nil,newEntry);
}
}
else if (sender == cppOptField)
{
[project setProjectDictObject:newEntry forKey:PCPreprocessorOptions];
}
else if (sender == objcOptField)
{
[project setProjectDictObject:newEntry forKey:PCObjCCompilerOptions];
}
else if (sender == cOptField)
{
[project setProjectDictObject:newEntry forKey:PCCompilerOptions];
}
else if ( sender == ldOptField )
{
[project setProjectDictObject:newEntry forKey:PCLinkerOptions];
}
// Project Description
else if ( sender == descriptionField )
{
[project setProjectDictObject:newEntry forKey:PCDescription];
}
else if ( sender == releaseField )
{
[project setProjectDictObject:newEntry forKey:PCRelease];
}
else if ( sender == licenseField )
{
[project setProjectDictObject:newEntry forKey:PCCopyright];
}
else if ( sender == licDescriptionField )
{
[project setProjectDictObject:newEntry forKey:PCCopyrightDescription];
}
else if ( sender == urlField )
{
[project setProjectDictObject:newEntry forKey:PCURL];
}
}
- (void)selectSectionWithTitle:(NSString *)sectionTitle
{
[inspectorPopup selectItemWithTitle:sectionTitle];
[self inspectorPopupDidChange:inspectorPopup];
}
// ============================================================================
// ==== Notifications
// ============================================================================
- (void)activeProjectDidChange:(NSNotification *)aNotif
{
project = [projectManager activeProject];
projectDict = [project projectDict];
PCLogStatus(self, @"Active projectChanged to %@",
[[project projectDict] objectForKey:PCProjectName]);
[inspectorPanel setTitle: [NSString stringWithFormat:
@"%@ - Project Inspector", [project projectName]]];
// 1. Get custom project attributes view
projectAttributesView = [project projectAttributesView];
// 2. Update values in UI elements
[self updateValues:nil];
// 3. Display current view
[self inspectorPopupDidChange:inspectorPopup];
}
- (void)updateValues:(NSNotification *)aNotif
{
// Build Attributes view
searchHeaders = [projectDict objectForKey:PCSearchHeaders];
searchLibs = [projectDict objectForKey:PCSearchLibs];
[self searchOrderPopupDidChange:searchOrderPopup];
[projectNameLabel setStringValue:[project projectName]];
[cppOptField setStringValue:
[projectDict objectForKey:PCPreprocessorOptions]];
[objcOptField setStringValue:
[projectDict objectForKey:PCObjCCompilerOptions]];
[cOptField setStringValue:
[projectDict objectForKey:PCCompilerOptions]];
[ldOptField setStringValue:
[projectDict objectForKey:PCLinkerOptions]];
[installPathField setStringValue:
[projectDict objectForKey:PCInstallDir]];
[toolField setStringValue:
[projectDict objectForKey:PCBuildTool]];
// Project Description view
[descriptionField setStringValue:
[projectDict objectForKey:PCDescription]];
[releaseField setStringValue:
[projectDict objectForKey:PCRelease]];
[licenseField setStringValue:
[projectDict objectForKey:PCCopyright]];
[licDescriptionField setStringValue:
[projectDict objectForKey:PCCopyrightDescription]];
[urlField setStringValue:
[projectDict objectForKey:PCURL]];
authorsItems = [projectDict objectForKey:PCAuthors];
[authorsList reloadData];
// File Attributes view
[self setFANameAndIcon:[project projectBrowser]];
}
// ============================================================================
// ==== Build Attributes
// ============================================================================
- (void)createBuildAttributes
{
if (buildAttributesView)
{
return;
}
if ([NSBundle loadNibNamed:@"BuildAttributes" owner:self] == NO)
{
PCLogError(self, @"error loading BuildAttributes NIB file!");
return;
}
// Search Order
// Popup
[searchOrderPopup removeAllItems];
[searchOrderPopup addItemWithTitle:@"Header Directories Search Order"];
[searchOrderPopup addItemWithTitle:@"Library Directories Search Order"];
[searchOrderPopup addItemWithTitle:@"Framework Directories Search Order"];
[searchOrderPopup selectItemAtIndex:0];
// Table column
searchOrderColumn = [[NSTableColumn alloc] initWithIdentifier: @"SO List"];
[searchOrderColumn setEditable:NO];
// Table
searchOrderList = [[NSTableView alloc]
initWithFrame:NSMakeRect(0,0,290,99)];
[searchOrderList setAllowsMultipleSelection:NO];
[searchOrderList setAllowsColumnReordering:NO];
[searchOrderList setAllowsColumnResizing:NO];
[searchOrderList setAllowsEmptySelection:YES];
[searchOrderList setAllowsColumnSelection:NO];
[searchOrderList setCornerView:nil];
[searchOrderList setHeaderView:nil];
[searchOrderList addTableColumn:searchOrderColumn];
[searchOrderList setDataSource:self];
[searchOrderList setDrawsGrid:NO];
[searchOrderList setTarget:self];
[searchOrderList setDoubleAction:@selector(searchOrderDoubleClick:)];
[searchOrderList setAction:@selector(searchOrderClick:)];
// ScrollView
[searchOrderScroll setDocumentView:searchOrderList];
[searchOrderScroll setHasHorizontalScroller:NO];
[searchOrderScroll setHasVerticalScroller:YES];
[searchOrderScroll setBorderType:NSBezelBorder];
RELEASE(searchOrderList);
// Buttons
[self setSearchOrderButtonsState];
[cppOptField setNextText:objcOptField];
[objcOptField setNextText:cOptField];
[cOptField setNextText:ldOptField];
[ldOptField setNextText:installPathField];
[installPathField setNextText:toolField];
[toolField setNextText:cppOptField];
// Retain view
[buildAttributesView retain];
}
// --- Search Order
- (void)searchOrderPopupDidChange:(id)sender
{
NSString *selectedTitle = [sender titleOfSelectedItem];
if ([selectedTitle isEqualToString: @"Header Directories Search Order"])
{
ASSIGN(searchItems, searchHeaders);
}
else if ([selectedTitle isEqualToString: @"Library Directories Search Order"])
{
ASSIGN(searchItems, searchLibs);
}
else
{
ASSIGN(searchItems,nil);
}
// Enable/disable buttons according to selected/not selected item
[self setSearchOrderButtonsState];
[searchOrderList reloadData];
}
- (void)searchOrderDoubleClick:(id)sender
{
}
- (void)searchOrderClick:(id)sender
{
// Warning! NSTableView doesn't call action method
// TODO: Fix NSTableView (NSCell/NSActionCell?)
[self setSearchOrderButtonsState];
}
- (void)setSearchOrderButtonsState
{
// Disable until implemented
[searchOrderSet setEnabled:NO];
return; // See searchOrderClick
if ([searchOrderList selectedRow] == -1)
{
[searchOrderRemove setEnabled:NO];
}
else
{
[searchOrderRemove setEnabled:YES];
}
}
- (void)setSearchOrder:(id)sender
{
}
- (void)removeSearchOrder:(id)sender
{
int row = [searchOrderList selectedRow];
if (row != -1)
{
[searchItems removeObjectAtIndex:row];
[self syncSearchOrder];
[searchOrderList reloadData];
}
}
- (void)addSearchOrder:(id)sender
{
NSString *value = [searchOrderTF stringValue];
[searchItems addObject:value];
[searchOrderTF setStringValue:@""];
[self syncSearchOrder];
[searchOrderList reloadData];
}
- (void)syncSearchOrder
{
int pIndex;
pIndex = [searchOrderPopup indexOfSelectedItem];
switch (pIndex)
{
case 0:
[project setProjectDictObject:searchItems forKey:PCSearchHeaders];
break;
case 1:
[project setProjectDictObject:searchItems forKey:PCSearchLibs];
break;
case 2:
return;
}
}
// ============================================================================
// ==== Project Description
// ============================================================================
- (void)createProjectDescription
{
if (projectDescriptionView)
{
return;
}
if ([NSBundle loadNibNamed:@"ProjectDescription" owner:self] == NO)
{
PCLogError(self, @"error loading ProjectDescription NIB file!");
return;
}
// Authors table
authorsColumn = [[NSTableColumn alloc] initWithIdentifier: @"Authors List"];
[authorsColumn setEditable:YES];
authorsList = [[NSTableView alloc]
initWithFrame:NSMakeRect(6,6,209,111)];
[authorsList setAllowsMultipleSelection:NO];
[authorsList setAllowsColumnReordering:NO];
[authorsList setAllowsColumnResizing:NO];
[authorsList setAllowsEmptySelection:YES];
[authorsList setAllowsColumnSelection:NO];
[authorsList setRowHeight:17.0];
[authorsList setCornerView:nil];
[authorsList setHeaderView:nil];
[authorsList addTableColumn:authorsColumn];
[authorsList setDataSource:self];
//
[authorsScroll setDocumentView:authorsList];
[authorsScroll setHasHorizontalScroller:NO];
[authorsScroll setHasVerticalScroller:YES];
[authorsScroll setBorderType:NSBezelBorder];
// Authors' buttons
[authorAdd setRefusesFirstResponder:YES];
[authorRemove setRefusesFirstResponder:YES];
[authorUp setRefusesFirstResponder:YES];
[authorUp setImage: [NSImage imageNamed:@"common_ArrowUp"]];
[authorDown setRefusesFirstResponder:YES];
[authorDown setImage: [NSImage imageNamed:@"common_ArrowDown"]];
// Link textfields
[descriptionField setNextText:releaseField];
[releaseField setNextText:licenseField];
[licenseField setNextText:licDescriptionField];
[licDescriptionField setNextText:urlField];
[urlField setNextText:descriptionField];
[projectDescriptionView retain];
}
// --- Actions
- (void)addAuthor:(id)sender
{
int row;
[authorsItems addObject:[NSMutableString stringWithString:@""]];
[authorsList reloadData];
row = [authorsItems count] - 1;
[authorsList selectRow:row byExtendingSelection:NO];
[authorsList editColumn:0 row:row withEvent:nil select:YES];
[project setProjectDictObject:authorsItems forKey:PCAuthors];
}
- (void)removeAuthor:(id)sender
{
int selectedRow = [authorsList selectedRow];
if (selectedRow >= 0)
{
[authorsItems removeObjectAtIndex:selectedRow];
[authorsList reloadData];
}
if ([authorsList selectedRow] < 0 && [authorsItems count] > 0)
{
[authorsList selectRow:[authorsItems count]-1 byExtendingSelection:NO];
}
[project setProjectDictObject:authorsItems forKey:PCAuthors];
}
- (void)upAuthor:(id)sender
{
int selectedRow = [authorsList selectedRow];
id previousRow;
id currentRow;
if (selectedRow > 0)
{
previousRow = [[authorsItems objectAtIndex: selectedRow-1] copy];
currentRow = [authorsItems objectAtIndex: selectedRow];
[authorsItems replaceObjectAtIndex: selectedRow-1 withObject: currentRow];
[authorsItems replaceObjectAtIndex: selectedRow withObject: previousRow];
[authorsList selectRow: selectedRow-1 byExtendingSelection: NO];
[authorsList reloadData];
[project setProjectDictObject:authorsItems forKey:PCAuthors];
}
}
- (void)downAuthor:(id)sender
{
int selectedRow = [authorsList selectedRow];
id nextRow;
id currentRow;
if (selectedRow < [authorsItems count]-1)
{
nextRow = [[authorsItems objectAtIndex: selectedRow+1] copy];
currentRow = [authorsItems objectAtIndex: selectedRow];
[authorsItems replaceObjectAtIndex: selectedRow+1 withObject: currentRow];
[authorsItems replaceObjectAtIndex: selectedRow withObject: nextRow];
[authorsList selectRow: selectedRow+1 byExtendingSelection: NO];
[authorsList reloadData];
[project setProjectDictObject:authorsItems forKey:PCAuthors];
}
}
// ============================================================================
// ==== File Attributes
// ============================================================================
- (void)createFileAttributes
{
if (fileAttributesView)
{
return;
}
if ([NSBundle loadNibNamed:@"FileAttributes" owner:self] == NO)
{
PCLogError(self, @"error loading ProjectDescription NIB file!");
return;
}
[fileAttributesView retain];
/* [[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(browserDidSetPath:)
name:PCBrowserDidSetPathNotification
object:[project projectBrowser]];*/
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(panelDidResignKey:)
name: NSWindowDidResignKeyNotification
object:inspectorPanel];
}
- (void)beginFileRename
{
[fileNameField setEditableField:YES];
[inspectorPanel makeFirstResponder:fileNameField];
}
- (void)setFANameAndIcon:(PCProjectBrowser *)browser
{
if (fileName != nil)
{
[fileName release];
}
fileName = [[browser nameOfSelectedFile] retain];
if (fileName)
{
[fileNameField setStringValue:fileName];
[fileIconView setImage:[[project projectWindow] fileIconImage]];
}
else if ([[browser selectedFiles] count] > 1)
{
[fileNameField setStringValue:@"Multiple files selected"];
[fileIconView setImage:[[project projectWindow] fileIconImage]];
}
else
{
[fileNameField setStringValue:@"No files selected"];
[fileIconView setImage:[NSImage imageNamed:@"common_Unknown"]];
}
}
- (void)fileNameDidChange:(id)sender
{
if ([fileName isEqualToString:[fileNameField stringValue]])
{
return;
}
PCLogInfo(self, @"{%@} file name changed from: %@ to: %@",
[project projectName], fileName, [fileNameField stringValue]);
if ([project renameFile:fileName toFile:[fileNameField stringValue]] == NO)
{
[fileNameField setStringValue:fileName];
}
}
// --- Notifications
- (void)browserDidSetPath:(NSNotification *)aNotif
{
[self setFANameAndIcon:[aNotif object]];
}
- (void)panelDidResignKey:(NSNotification *)aNotif
{
if ([fileNameField isEditable] == YES)
{
[inspectorPanel makeFirstResponder:fileIconView];
[fileNameField setStringValue:fileName];
}
}
// ============================================================================
// ==== NSTableViews
// ============================================================================
- (int)numberOfRowsInTableView: (NSTableView *)aTableView
{
if (searchOrderList != nil && aTableView == searchOrderList)
{
return [searchItems count];
}
else if (authorsList != nil && aTableView == authorsList)
{
return [authorsItems count];
}
return 0;
}
- (id) tableView: (NSTableView *)aTableView
objectValueForTableColumn: (NSTableColumn *)aTableColumn
row: (int)rowIndex
{
if (searchOrderList != nil && aTableView == searchOrderList)
{
return [searchItems objectAtIndex:rowIndex];
}
else if (authorsList != nil && aTableView == authorsList)
{
return [authorsItems objectAtIndex:rowIndex];
}
return nil;
}
- (void) tableView:(NSTableView *)aTableView
setObjectValue:anObject
forTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex
{
if (authorsList != nil && aTableView == authorsList)
{
if([authorsItems count] <= 0)
{
return;
}
[authorsItems removeObjectAtIndex:rowIndex];
[authorsItems insertObject:anObject atIndex:rowIndex];
[project setProjectDictObject:authorsItems forKey:PCAuthors];
}
}
@end

View file

@ -0,0 +1,93 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2000-2002 Free Software Foundation
Author: Philippe C.D. Robert <probert@siggraph.org>
This file is part of GNUstep.
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#ifndef __PCPROJECTDEBUGGER_H
#define __PCPROJECTDEBUGGER_H
#include <AppKit/AppKit.h>
#ifndef GNUSTEP_BASE_VERSION
@protocol ProjectComponent;
#else
#include <ProjectCenter/ProjectComponent.h>
#endif
@class PCProject;
@class PCButton;
@interface PCProjectLauncher : NSObject <ProjectComponent>
{
PCProject *project; // Not retained!
NSDictionary *currentOptions; // Not retained!
NSBox *componentView;
PCButton *runButton;
PCButton *debugButton;
NSTextView *stdOut;
NSDictionary *textAttributes;
NSFileHandle *readHandle;
NSFileHandle *errorReadHandle;
NSTask *launchTask;
BOOL _isRunning;
BOOL _isDebugging;
}
- (id)initWithProject:(PCProject *)aProject;
- (void)dealloc;
- (NSView *) componentView;
- (void)setTooltips;
- (BOOL)isRunning;
- (BOOL)isDebugging;
- (void)performRun;
- (void)performDebug;
- (void)debug:(id)sender;
- (void)run:(id)sender;
- (void)runDidTerminate:(NSNotification *)aNotif;
- (void)logStdOut:(NSNotification *)aNotif;
- (void)logErrOut:(NSNotification *)aNotif;
@end
@interface PCProjectLauncher (BuildLogging)
- (void)logString:(NSString *)string newLine:(BOOL)newLine;
- (void)logData:(NSData *)data error:(BOOL)yn;
@end
@interface PCProjectLauncher (UserInterface)
- (void)_createComponentView;
@end
#endif

438
Library/PCProjectLauncher.m Normal file
View file

@ -0,0 +1,438 @@
/*
GNUstep ProjectCenter - http://www.gnustep.org
Copyright (C) 2000-2002 Free Software Foundation
Author: Philippe C.D. Robert <probert@siggraph.org>
This file is part of GNUstep.
This application is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This application is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
#include "PCProjectLauncher.h"
#include "PCDefines.h"
#include "PCProject.h"
#include "PCProjectManager.h"
#include "PCButton.h"
#include "PCLogController.h"
#include <AppKit/AppKit.h>
#ifndef NOTIFICATION_CENTER
#define NOTIFICATION_CENTER [NSNotificationCenter defaultCenter]
#endif
#ifndef IMAGE
#define IMAGE(X) [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForImageResource:(X)]] autorelease]
#endif
enum {
DEBUG_DEFAULT_TARGET = 1,
DEBUG_DEBUG_TARGET = 2
};
@protocol Terminal
- (BOOL)terminalRunProgram:(NSString *)path
withArguments:(NSArray *)args
inDirectory:(NSString *)directory
properties:(NSDictionary *)properties;
@end
@implementation PCProjectLauncher (UserInterface)
- (void)_createComponentView
{
NSScrollView *scrollView;
NSString *string;
NSAttributedString *attributedString;
componentView = [[NSBox alloc] initWithFrame:NSMakeRect(8,-1,464,322)];
[componentView setTitlePosition:NSNoTitle];
[componentView setBorderType:NSNoBorder];
[componentView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[componentView setContentViewMargins: NSMakeSize(0.0,0.0)];
/*
* Top buttons
*/
runButton = [[PCButton alloc] initWithFrame: NSMakeRect(0,271,43,43)];
[runButton setTitle: @"Run"];
[runButton setImage: IMAGE(@"Run")];
[runButton setAlternateImage: IMAGE(@"Stop")];
[runButton setTarget: self];
[runButton setAction: @selector(run:)];
[runButton setAutoresizingMask: (NSViewMaxXMargin | NSViewMinYMargin)];
[runButton setButtonType: NSToggleButton];
[componentView addSubview: runButton];
RELEASE (runButton);
debugButton = [[PCButton alloc] initWithFrame: NSMakeRect(44,271,43,43)];
[debugButton setTitle: @"Debug"];
[debugButton setImage: IMAGE(@"Debug")];
[debugButton setAlternateImage: IMAGE(@"Stop")];
[debugButton setTarget: self];
[debugButton setAction: @selector(debug:)];
[debugButton setAutoresizingMask: (NSViewMaxXMargin | NSViewMinYMargin)];
[debugButton setButtonType: NSToggleButton];
[componentView addSubview: debugButton];
RELEASE (debugButton);
/*
*
*/
scrollView = [[NSScrollView alloc] initWithFrame:NSMakeRect (0,0,464,255)];
[scrollView setHasHorizontalScroller:NO];
[scrollView setHasVerticalScroller:YES];
[scrollView setBorderType: NSBezelBorder];
[scrollView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
stdOut=[[NSTextView alloc] initWithFrame:[[scrollView contentView] frame]];
[stdOut setMinSize: NSMakeSize(0, 0)];
[stdOut setMaxSize: NSMakeSize(1e7, 1e7)];
[stdOut setRichText:YES];
[stdOut setEditable:NO];
[stdOut setSelectable:YES];
[stdOut setVerticallyResizable: YES];
[stdOut setHorizontallyResizable: NO];
[stdOut setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
[[stdOut textContainer] setWidthTracksTextView:YES];
[[stdOut textContainer] setContainerSize:
NSMakeSize([stdOut frame].size.width, 1e7)];
// Font
string = [NSString stringWithString:@"=== Launcher ready ==="];
attributedString =
[[NSAttributedString alloc] initWithString:string
attributes:textAttributes];
[[stdOut textStorage] setAttributedString:attributedString];
[scrollView setDocumentView:stdOut];
RELEASE (stdOut);
[componentView addSubview: scrollView];
RELEASE(scrollView);
}
@end
@implementation PCProjectLauncher
- (id)initWithProject:(PCProject *)aProject
{
NSAssert (aProject, @"No project specified!");
if ((self = [super init]))
{
NSFont *font = [NSFont userFixedPitchFontOfSize: 10.0];
project = aProject;
textAttributes =
[NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
[textAttributes retain];
}
return self;
}
- (void)dealloc
{
NSLog (@"PCProjectLauncher: dealloc");
RELEASE (componentView);
RELEASE (textAttributes);
[super dealloc];
}
- (NSView *)componentView;
{
if (!componentView)
{
[self _createComponentView];
}
return componentView;
}
- (void)setTooltips
{
[runButton setShowTooltip:YES];
[debugButton setShowTooltip:YES];
}
- (BOOL)isRunning
{
return _isRunning;
}
- (BOOL)isDebugging
{
return _isDebugging;
}
- (void)performRun
{
if (!_isRunning && !_isDebugging)
{
[runButton performClick:self];
}
}
- (void)performDebug
{
if (!_isRunning && !_isDebugging)
{
[debugButton performClick:self];
}
}
- (void)debug:(id)sender
{
NSString *dp = [project projectName];
NSString *fp = nil;
NSString *pn = nil;
NSString *gdbPath = nil;
NSArray *args = nil;
NSDistantObject <Terminal> *terminal;
NSFileManager *fm = [NSFileManager defaultManager];
/* Get the Terminal application */
terminal = (NSDistantObject<Terminal> *)[NSConnection
rootProxyForConnectionWithRegisteredName:@"Terminal" host:nil];
if (terminal == nil)
{
NSRunAlertPanel(@"Attention!",
@"Run Terminal application first",
@"Close",nil,nil);
[debugButton setState:NSOffState];
return;
}
// Executable
pn = [dp stringByAppendingPathExtension:@"debug"];
fp = [project projectPath];
fp = [fp stringByAppendingPathComponent:pn];
fp = [fp stringByAppendingPathComponent:dp];
PCLogInfo(self, @"debug: %@", fp);
if ([fm isExecutableFileAtPath:fp] == NO)
{
NSRunAlertPanel(@"Attention!",
@"Can't execute %@!",
@"Abort",nil,nil,pn);
[debugButton setState:NSOffState];
return;
}
// Debugger
gdbPath = [[NSUserDefaults standardUserDefaults] objectForKey:Debugger];
if (gdbPath == nil)
{
gdbPath = [NSString stringWithString:@"/usr/bin/gdb"];
}
if ([fm isExecutableFileAtPath:gdbPath] == NO)
{
NSRunAlertPanel(@"Attention!",
@"Invalid debugger specified: %@!",
@"Abort",nil,nil,dp);
[debugButton setState:NSOffState];
return;
}
// Task
args = [[NSArray alloc] initWithObjects:gdbPath, @"--args", fp, nil];
[terminal terminalRunProgram:AUTORELEASE(gdbPath)
withArguments:args
inDirectory:nil
properties:nil];
[debugButton setState:NSOffState];
/* RELEASE(args);
[runButton setEnabled:NO];
_isDebugging = YES;*/
}
- (void)run:(id)sender
{
NSMutableArray *args = [[NSMutableArray alloc] init];
NSPipe *logPipe;
NSPipe *errorPipe;
NSString *openPath;
// Check if project type is executable
if ([project isExecutable])
{
openPath = [project execToolName];
[args addObject:[project projectName]];
}
else
{
NSRunAlertPanel(@"Attention!",
@"The project is not executable",
@"Close", nil, nil, nil);
return;
}
// [makeTask isRunning] doesn't work here.
// "waitpid 7045, result -1, error No child processes" is printed.
if (launchTask)
{
PCLogStatus(self, @"task will terminate");
[launchTask terminate];
return;
}
// Setting I/O
logPipe = [NSPipe pipe];
RELEASE(readHandle);
readHandle = [[logPipe fileHandleForReading] retain];
[stdOut setString:@""];
[readHandle waitForDataInBackgroundAndNotify];
[NOTIFICATION_CENTER addObserver:self
selector:@selector(logStdOut:)
name:NSFileHandleDataAvailableNotification
object:readHandle];
errorPipe = [NSPipe pipe];
RELEASE(errorReadHandle);
errorReadHandle = [[errorPipe fileHandleForReading] retain];
[stdOut setString:@""];
[errorReadHandle waitForDataInBackgroundAndNotify];
[NOTIFICATION_CENTER addObserver:self
selector:@selector(logErrOut:)
name:NSFileHandleDataAvailableNotification
object:errorReadHandle];
// Launch task
RELEASE(launchTask);
launchTask = [[NSTask alloc] init];
[NOTIFICATION_CENTER addObserver:self
selector:@selector(runDidTerminate:)
name:NSTaskDidTerminateNotification
object:launchTask];
[launchTask setArguments:args];
[launchTask setCurrentDirectoryPath:[project projectPath]];
[launchTask setLaunchPath:openPath];
[launchTask setStandardOutput:logPipe];
[launchTask setStandardError:errorPipe];
[launchTask launch];
[debugButton setEnabled:NO];
_isRunning = YES;
RELEASE(args);
}
- (void)runDidTerminate:(NSNotification *)aNotif
{
if ([aNotif object] != launchTask)
{
return;
}
[NOTIFICATION_CENTER removeObserver:self];
[runButton setState:NSOffState];
[debugButton setState:NSOffState];
[runButton setEnabled:YES];
[debugButton setEnabled:YES];
[componentView display];
RELEASE(launchTask);
launchTask = nil;
_isRunning = NO;
_isDebugging = NO;
}
- (void)logStdOut:(NSNotification *)aNotif
{
NSData *data;
if ((data = [readHandle availableData]))
{
[self logData:data error:NO];
}
[readHandle waitForDataInBackgroundAndNotifyForModes:nil];
}
- (void)logErrOut:(NSNotification *)aNotif
{
NSData *data;
if ((data = [errorReadHandle availableData]))
{
[self logData:data error:YES];
}
[errorReadHandle waitForDataInBackgroundAndNotifyForModes:nil];
}
@end
@implementation PCProjectLauncher (BuildLogging)
- (void)logString:(NSString *)str newLine:(BOOL)newLine
{
[stdOut replaceCharactersInRange:NSMakeRange([[stdOut string] length],0)
withString:str];
if (newLine) {
[stdOut replaceCharactersInRange:NSMakeRange([[stdOut string] length], 0)
withString:@"\n"];
}
else {
[stdOut replaceCharactersInRange:NSMakeRange([[stdOut string] length], 0)
withString:@" "];
}
[stdOut scrollRangeToVisible:NSMakeRange([[stdOut string] length], 0)];
}
- (void)logData:(NSData *)data error:(BOOL)yn
{
NSString *s = nil;
NSAttributedString *as = nil;
// [self logString:s newLine:NO];
s = [[NSString alloc] initWithData:data
encoding:[NSString defaultCStringEncoding]];
as = [[NSAttributedString alloc] initWithString:s
attributes:textAttributes];
[[stdOut textStorage] appendAttributedString: as];
[stdOut scrollRangeToVisible:NSMakeRange([[stdOut string] length], 0)];
[s release];
[as release];
}
@end

View file

@ -0,0 +1,61 @@
/*
* Project ProjectCenter
*/
#ifndef _PCProjectLoadedFiles_h_
#define _PCProjectLoadedFiles_h_
#include <AppKit/AppKit.h>
@class PCProject;
typedef enum _PHSortType
{
PHSortByTime,
PHSortByName
} PHSortType;
@interface PCProjectLoadedFiles : NSObject
{
PCProject *project;
NSTableView *filesList;
NSTableColumn *filesColumn;
NSScrollView *filesScroll;
NSMutableArray *editedFiles;
PHSortType sortType;
}
- (id)initWithProject:(PCProject *)aProj;
- (void)dealloc;
- (NSView *)componentView;
- (NSArray *)editedFilesRep;
- (void)setSortType:(PHSortType)type;
- (void)setSortByTime;
- (void)setSortByName;
- (void)selectNextFile;
- (void)selectPreviousFile;
- (void)click:(id)sender;
- (void)doubleClick:(id)sender;
@end
@interface PCProjectLoadedFiles (HistoryTableDelegate)
- (int)numberOfRowsInTableView:(NSTableView *)aTableView;
- (id) tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex;
- (void)tableView:(NSTableView *)aTableView
setObjectValue:anObject
forTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex;
@end
#endif

View file

@ -0,0 +1,336 @@
/*
* Project ProjectCenter
*/
#include "PCDefines.h"
#include "PCProject.h"
#include "PCProjectEditor.h"
#include "PCEditor.h"
#include "PCPrefController.h"
#include "PCLogController.h"
#include "PCProjectLoadedFiles.h"
@implementation PCProjectLoadedFiles
- (id)initWithProject:(PCProject *)aProj
{
NSAssert(aProj, @"Project is mandatory!");
NSLog(@"PCProjectLoadedFiles: init");
if ((self = [super init]))
{
project = aProj;
editedFiles = [[NSMutableArray alloc] init];
// Column
filesColumn = [[NSTableColumn alloc] initWithIdentifier:@"Files List"];
[filesColumn setEditable:NO];
// Table
filesList = [[NSTableView alloc]
initWithFrame:NSMakeRect(0,0,160,128)];
[filesList setAllowsMultipleSelection:NO];
[filesList setAllowsColumnReordering:NO];
[filesList setAllowsColumnResizing:NO];
[filesList setAllowsEmptySelection:YES];
[filesList setAllowsColumnSelection:NO];
[filesList setCornerView:nil];
[filesList setHeaderView:nil];
[filesList addTableColumn:filesColumn];
[filesList setDataSource:self];
/* [filesList setBackgroundColor: [NSColor colorWithDeviceRed:0.88
green:0.76
blue:0.60
alpha:1.0]];*/
// Hack! Should be [filesList setDrawsGrid:NO]
[filesList setGridColor: [NSColor lightGrayColor]];
[filesList setTarget:self];
[filesList setDoubleAction:@selector(doubleClick:)];
[filesList setAction:@selector(click:)];
// Scrollview
filesScroll = [[NSScrollView alloc] initWithFrame:
NSMakeRect (0, 0, 80, 128)];
[filesScroll setDocumentView:filesList];
[filesScroll setHasHorizontalScroller:NO];
[filesScroll setHasVerticalScroller:YES];
if ([[[[NSUserDefaults standardUserDefaults] dictionaryRepresentation]
objectForKey: SeparateLoadedFiles] isEqualToString: @"NO"])
{
[filesScroll setBorderType:NSBezelBorder];
}
sortType = PHSortByTime;
[filesList reloadData];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(fileDidOpen:)
name:PCEditorDidOpenNotification
object:nil];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(fileDidClose:)
name:PCEditorDidCloseNotification
object:nil];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(editorDidBecomeActive:)
name:PCEditorDidBecomeActiveNotification
object:nil];
}
return self;
}
- (void)dealloc
{
NSLog (@"PCProjectLoadedFiles: dealloc");
[[NSNotificationCenter defaultCenter] removeObserver:self];
RELEASE(filesColumn);
RELEASE(filesList);
RELEASE(filesScroll);
RELEASE(editedFiles);
[super dealloc];
}
- (NSView *)componentView
{
return filesScroll;
}
- (NSArray *)editedFilesRep
{
if (sortType == PHSortByName)
{
NSArray *sortedArray = nil;
sortedArray = [editedFiles
sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
return sortedArray;
}
return editedFiles;
}
- (void)setSortType:(PHSortType)type
{
int row;
NSString *filePath = nil;
if ([editedFiles count] > 0)
{
row = [filesList selectedRow];
filePath = [[self editedFilesRep] objectAtIndex:row];
}
sortType = type;
[filesList reloadData];
if ([editedFiles count] > 0)
{
row = [[self editedFilesRep] indexOfObject:filePath];
[filesList selectRow:row byExtendingSelection:NO];
}
}
- (void)setSortByTime
{
[self setSortType:PHSortByTime];
}
- (void)setSortByName
{
[self setSortType:PHSortByName];
}
- (void)selectNextFile
{
int row = [filesList selectedRow];
if (row == ([filesList numberOfRows]-1))
{
[filesList selectRow:0 byExtendingSelection:NO];
}
else
{
[filesList selectRow:row+1 byExtendingSelection:NO];
}
[self click:self];
}
- (void)selectPreviousFile
{
int row = [filesList selectedRow];
if (row == 0)
{
[filesList selectRow:[filesList numberOfRows]-1 byExtendingSelection:NO];
}
else
{
[filesList selectRow:row-1 byExtendingSelection:NO];
}
[self click:self];
}
- (void)click:(id)sender
{
int row = [filesList selectedRow];
NSString *path = [[self editedFilesRep] objectAtIndex:row];
[[project projectEditor] orderFrontEditorForFile:path];
}
- (void)doubleClick:(id)sender
{
// TODO: Open separate editor window for file
PCLogInfo(self, @"ProjectLoadedFiles doubleClick received");
}
// ===========================================================================
// ==== Notifications
// ===========================================================================
- (void)fileDidOpen:(NSNotification *)aNotif
{
PCEditor *editor = [aNotif object];
NSString *filePath = nil;
int row;
if ([editor projectEditor] != [project projectEditor])
{
PCLogWarning(self, @"File opened from other project");
return;
}
PCLogInfo(self, @"File did open in project %@", [project projectName]);
filePath = [editor path];
if ([editedFiles containsObject:filePath] == YES)
{
[editedFiles removeObject:filePath];
}
[editedFiles insertObject:filePath atIndex:0];
[filesList reloadData];
row = [[self editedFilesRep] indexOfObject:filePath];
[filesList selectRow:row byExtendingSelection:NO];
PCLogInfo(self, @"fileDidOpen.END");
}
- (void)fileDidClose:(NSNotification *)aNotif
{
PCEditor *editor = [aNotif object];
NSString *filePath = [editor path];
if ([editor projectEditor] != [project projectEditor])
{
PCLogWarning(self, @"File from other project closed");
return;
}
if ([editedFiles containsObject:filePath] == YES)
{
[editedFiles removeObject:filePath];
[filesList reloadData];
if ([editedFiles count] > 0)
{
unsigned row;
filePath = [editedFiles objectAtIndex:0];
row = [[self editedFilesRep] indexOfObject:filePath];
[filesList selectRow:row byExtendingSelection:NO];
}
}
}
- (void)editorDidBecomeActive:(NSNotification *)aNotif
{
PCEditor *editor = [aNotif object];
NSString *filePath = nil;
unsigned index;
if ([editor projectEditor] != [project projectEditor])
{
return;
}
if ([editedFiles count] > 0)
{
filePath = [editor path];
index = [[self editedFilesRep] indexOfObject:filePath];
[filesList selectRow:index byExtendingSelection:NO];
}
}
@end
@implementation PCProjectLoadedFiles (LoadedFilesTableDelegate)
- (int)numberOfRowsInTableView: (NSTableView *)aTableView
{
if (aTableView != filesList)
{
return 0;
}
return [editedFiles count];
}
- (id) tableView: (NSTableView *)aTableView
objectValueForTableColumn: (NSTableColumn *)aTableColumn
row: (int)rowIndex
{
if (aTableView != filesList)
{
return nil;
}
if (sortType == PHSortByName)
{
NSArray *sortedArray = nil;
sortedArray = [editedFiles
sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
return [[sortedArray objectAtIndex:rowIndex] lastPathComponent];
}
return [[editedFiles objectAtIndex:rowIndex] lastPathComponent];
}
- (void) tableView:(NSTableView *)aTableView
setObjectValue:anObject
forTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex
{
/* NSString *path = nil;
NSParameterAssert (rowIndex >= 0 && rowIndex < [editedFiles count]);
[editedFiles removeObjectAtIndex:rowIndex];
[editedFiles insertObject:anObject atIndex:rowIndex];
path =
[filesPath removeObjectAtIndex:rowIndex];
[filesPath insertObject:[editor path] atIndex:rowIndex];*/
}
@end

View file

@ -20,16 +20,23 @@
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$Id$
*/
#ifndef _PCPROJECTMANAGER_H
#define _PCPROJECTMANAGER_H
#ifndef _PCProjectManager_h_
#define _PCProjectManager_h_
#include <AppKit/AppKit.h>
@class PCBundleLoader;
@class PCFileManager;
@class PCProject;
@class PCProjectInspector;
@class PCProjectBuilder;
@class PCProjectLauncher;
@class PCProjectLoadedFiles;
@class PCProjectFinder;
@class NewSubprojectController;
#ifndef GNUSTEP_BASE_VERSION
@protocol ProjectBuilder;
@ -39,72 +46,99 @@
#include <ProjectCenter/ProjectDelegate.h>
#endif
extern NSString *PCActiveProjectDidChangeNotification;
@interface PCProjectManager : NSObject <ProjectBuilder>
{
id<ProjectDelegate> delegate; // The PCAppController
id fileManager;
id delegate;
id prefController;
id inspector;
id inspectorView;
id inspectorPopup;
PCBundleLoader *bundleLoader;
NSMutableDictionary *projectTypes;
PCFileManager *fileManager;
PCProjectInspector *projectInspector;
NSPanel *buildPanel;
NSPanel *launchPanel;
NSPanel *loadedFilesPanel;
NSPanel *findPanel;
NSMutableDictionary *loadedProjects;
PCProject *activeProject;
NSString *rootBuildPath;
NSTimer *saveTimer;
NSMutableDictionary *nonProjectEditors;
NSBox *projectTypeAccessaryView;
id projectTypePopup;
NSBox *fileTypeAccessaryView;
id fileTypePopup;
IBOutlet NSPanel *nsPanel;
IBOutlet NSImageView *nsImage;
IBOutlet NSTextField *nsTitle;
IBOutlet NSTextField *projectNameField;
IBOutlet NSTextField *nsNameField;
IBOutlet NSPopUpButton *nsTypePB;
IBOutlet NSButton *nsCancelButton;
IBOutlet NSButton *nsCreateButton;
@private
BOOL _needsReleasing;
BOOL _needsReleasing;
}
// ===========================================================================
// ============================================================================
// ==== Intialization & deallocation
// ===========================================================================
// ============================================================================
- (id)init;
- (void)dealloc;
// ===========================================================================
// ==== Delegate
// ===========================================================================
- (id)delegate;
- (void)createProjectTypeAccessaryView;
- (void)setDelegate:(id)aDelegate;
- (id)delegate;
- (void)setPrefController:(id)aController;
- (id)prefController;
// ===========================================================================
// ============================================================================
// ==== Timer handling
// ===========================================================================
// ============================================================================
- (BOOL)startSaveTimer;
- (BOOL)resetSaveTimer:(NSNotification *)notif;
- (BOOL)stopSaveTimer;
- (void)resetSaveTimer:(NSNotification *)notif;
// ============================================================================
// ==== Accessory methods
// ============================================================================
- (PCFileManager *)fileManager;
- (PCProjectInspector *)projectInspector;
- (NSPanel *)inspectorPanel;
- (void)showProjectInspector:(id)sender;
- (NSPanel *)loadedFilesPanel;
- (void)showProjectLoadedFiles:(id)sender;
- (NSPanel *)buildPanel;
- (NSPanel *)launchPanel;
- (NSPanel *)projectFinderPanel;
- (NSString *)rootBuildPath;
- (NSString *)projectPath;
- (NSString *)selectedFileName;
// ===========================================================================
// ============================================================================
// ==== Project management
// ===========================================================================
// ============================================================================
// Returns all currently loaded projects. They are stored with their absolut
// paths as the keys.
- (NSMutableDictionary *)loadedProjects;
// Returns the currently active project
- (PCProject *)activeProject;
// Sets the new currently active project
- (PCProject *)rootActiveProject;
- (void)setActiveProject:(PCProject *)aProject;
// Gets set while initialising!
- (NSString *)rootBuildPath;
// Returns active project's path
- (NSString *)projectPath;
// Returns name of file selected in browser(and visible in internal editor)
- (NSString *)selectedFileName;
// ===========================================================================
// ============================================================================
// ==== Project actions
// ===========================================================================
// ============================================================================
// Returns the loaded project if the builder class is known, nil else.
- (PCProject *)loadProjectAt:(NSString *)aPath;
@ -112,69 +146,59 @@
// Invokes loadProjectAt to load the project properly.
- (BOOL)openProjectAt:(NSString *)aPath;
// projectType is exactly the name of the class to be invoked to create the
// project!
- (BOOL)createProjectOfType:(NSString *)projectType path:(NSString *)aPath;
- (PCProject *)createProjectOfType:(NSString *)projectType
path:(NSString *)aPath;
// Saves the current project
- (void)openProject;
- (void)newProject;
- (BOOL)saveProject;
// Calls saveAllProjects if the preferences are setup accordingly.
- (void)saveAllProjectsIfNeeded;
// Saves all projects if needed.
- (void)saveAllProjects;
- (BOOL)saveProjectAs:(NSString *)projName;
- (void)inspectorPopupDidChange:(id)sender;
- (void)showInspectorForProject:(PCProject *)aProject;
// Opens the inspector for aProject
- (void)revertToSaved;
// Reverts the currently active project
- (BOOL)newSubproject;
- (BOOL)addSubprojectAt:(NSString *)path;
- (void)removeSubproject;
- (BOOL)saveAllProjects;
- (BOOL)addProjectFiles;
- (BOOL)saveProjectFiles;
- (BOOL)removeProjectFiles;
- (void)closeProject:(PCProject *)aProject;
- (void)closeProject;
// Closes the currently active project
- (BOOL)closeAllProjects;
// ===========================================================================
// ============================================================================
// ==== File actions
// ===========================================================================
// ============================================================================
- (BOOL)saveAllFiles;
- (void)openFile;
- (void)newFile;
- (BOOL)saveFile;
- (BOOL)saveFileAs:(NSString *)path;
- (BOOL)saveFileTo:(NSString *)path;
- (BOOL)saveFileTo;
- (BOOL)revertFileToSaved;
- (BOOL)renameFile;
- (void)closeFile;
- (BOOL)renameFileTo:(NSString *)path;
- (BOOL)removeFilesPermanently:(BOOL)yn;
// ============================================================================
// ==== Non project editors
// ============================================================================
- (void)openFileWithEditor:(NSString *)path;
- (void)editorDidClose:(NSNotification *)aNotif;
@end
@interface PCProjectManager (FileManagerDelegates)
- (NSString *)fileManager:(id)sender willCreateFile:(NSString *)aFile withKey:(NSString *)key;
// Returns the full path if the type is valid, nil else.
// Returns the full path if the type is valid, nil else.
- (NSString *)fileManager:(id)sender
willCreateFile:(NSString *)aFile
withKey:(NSString *)key;
- (void)fileManager:(id)sender didCreateFile:(NSString *)aFile withKey:(NSString *)key;
// Adds the file to the project and updates the makefile!
- (id)fileManagerWillAddFiles:(id)sender;
// Returns the active project
- (BOOL)fileManager:(id)sender shouldAddFile:(NSString *)file forKey:(NSString *)key;
- (void)fileManager:(id)sender didAddFile:(NSString *)file forKey:(NSString *)key;
// Adds the file to the project and update the makefile!
// Adds the file to the project and updates the makefile!
- (void)fileManager:(id)sender
didCreateFile:(NSString *)aFile
withKey:(NSString *)key;
@end
@ -187,6 +211,35 @@
@end
extern NSString *ActiveProjectDidChangeNotification;
@interface NewSubprojectController : NSWindowController
{
id image;
id nameTextField;
id typePopup;
id createButton;
id cancelButton;
}
@end
@interface PCProjectManager (ProjectRegistration)
- (void)loadProjectTypeBunldes;
- (PCBundleLoader *)bundleLoader;
- (NSDictionary *)projectTypes;
- (void)bundleLoader:(id)sender didLoadBundle:(NSBundle *)aBundle;
@end
@interface PCProjectManager (Subprojects)
- (BOOL)newSubproject;
- (BOOL)addSubproject;
- (void)closeNewSubprojectPanel:(id)sender;
- (BOOL)createSubproject:(id)sender;
- (PCProject *)createSubprojectOfType:(NSString *)projectType
path:(NSString *)aPath;
- (BOOL)createSubproject;
@end
#endif

Some files were not shown because too many files have changed in this diff Show more