ProjectManager  0.2
GNUstepAppLauncher.h
00001 /*
00002     GNUstepAppLauncher.h
00003 
00004     Interface declaration of the GNUstepAppLauncher project module for the
00005     ProjectManager application.
00006 
00007     Copyright (C) 2005, 2006  Saso Kiselkov
00008 
00009     This program is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     This program is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU General Public License for more details.
00018 
00019     You should have received a copy of the GNU General Public License
00020     along with this program; if not, write to the Free Software
00021     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022 */
00023 
00024 #import <Foundation/NSObject.h>
00025 #import "../../ProjectModule.h"
00026 
00027 @class NSMutableArray,
00028        NSMutableDictionary,
00029        NSTask,
00030        NSFileHandle,
00031        NSNotification,
00032        NSTableView,
00033        NSTableColumn;
00034 
00035 @protocol GNUstepAppLauncherDelegate;
00036 
00037 extern NSString * const GNUstepAppLauncherProjectWillLaunchNotification;
00038 extern NSString * const GNUstepAppLauncherProjectDidLaunchNotification;
00039 extern NSString * const GNUstepAppLauncherProjectDidFailToLaunchNotification;
00040 extern NSString * const GNUstepAppLauncherProjectDidTerminateNotification;
00041 
00042 typedef enum {
00043   GNUstepAppLauncherReadyState,
00044   GNUstepAppLauncherDelayedLaunchState,
00045   GNUstepAppLauncherLaunchedState
00046 } GNUstepAppLauncherState;
00047 
00048 @interface GNUstepAppLauncher : NSObject <ProjectModule>
00049 {
00050   ProjectDocument * document;
00051 
00052   id bogusWindow, view;
00053 
00054   id stderr;
00055   id stdout;
00056   id stdin;
00057   id workingDirectory;
00058   id workingDirectoryButton;
00059   id targets;
00060   // holds the name of the target which was chose when `Launch' was hit
00061   NSString * target;
00062 
00063   id args, env;
00064   id argsPanel, envPanel;
00065   // When we resign being the current project module the arguments
00066   // and environment panel are closed to not collide with any other
00067   // panels. In these ivars we store whether the panels were open
00068   // when the module was changed, so that later on when we again
00069   // become the current module we know whether we need to open them
00070   // open again
00071   BOOL argsPanelWasOpen, envPanelWasOpen;
00072 
00073   NSMutableArray * arguments;
00074   NSMutableDictionary * environment;
00075   NSArray * sortedEnvironmentNames;
00076 
00077   NSTask * task;
00078   NSFileHandle * stdinHandle,
00079                * stdoutHandle,
00080                * stderrHandle;
00081 
00082   id <GNUstepAppLauncherDelegate> delegate;     // weak reference
00083 
00084   GNUstepAppLauncherState launcherState;
00085 }
00086 
00087 - (void) appendStdoutMessage: (NSString *) aMessage;
00088 - (void) appendStderrMessage: (NSString *) aMessage;
00089 
00090 - (void) launch: (id) sender;
00091 - (void) proceedWithLaunch: (BOOL) flag;
00092 
00093 - (void) kill: (id) sender;
00094 - (void) stopLaunch: (id) sender;
00095 
00096 - (void) chooseWorkingDirectory: (id) sender;
00097 - (void) showArguments: (id) sender;
00098 - (void) showEnvironment: (id) sender;
00099 - (void) writeStdin: (id) sender;
00100 
00101 - (void) addArg: sender;
00102 - (void) removeArg: sender;
00103 - (void) moveArgUp: sender;
00104 - (void) moveArgDown: sender;
00105 
00106 - (void) addEnv: sender;
00107 - (void) removeEnv: sender;
00108 
00109 - (void) moduleChanged: (NSNotification *) notif;
00110 
00111 // notification invoked when the task terminates
00112 - (void) taskTerminated;
00113 
00114 // notifications for collecting stdout/err output
00115 - (void) readStdout;
00116 - (void) readStderr;
00117 
00118 // table view data source methods
00119 - (int) numberOfRowsInTableView: (NSTableView *)aTableView;
00120 - (id) tableView: (NSTableView *)aTableView 
00121 objectValueForTableColumn: (NSTableColumn *)aTableColumn 
00122              row: (int)rowIndex;
00123 - (void) tableView: (NSTableView *)aTableView 
00124     setObjectValue: (id)anObject 
00125     forTableColumn: (NSTableColumn *)aTableColumn
00126                row: (int)rowIndex;
00127 
00128 @end