///////////////////////////////////////////////////////////////////////////////
// $Revision: 1.145.4.15 $
///////////////////////////////////////////////////////////////////////////////
#pragma option(strict,on)
#include 'slick.sh'
#include 'tagsdb.sh'
#include 'project.sh'
#include "codetemplate.sh"
// Track add, remove, and refresh files instead of just checking modify
static boolean gFileListModified;
static _str gDialog;
static _str gSetActiveConfigTo;
static _str gProjectName;
static int gProjectHandle;
static int gOrigProjectHandle;
static boolean gdoSaveIfNecessary;
static boolean gMakeCopyFirst;
static boolean gIsProjectTemplate;
static _str gConfigName;
static _str gConfigList[];
static boolean gChangingConfiguration;
static _str gAssociatedFile;
static _str gAssociatedFileType;
static _str gInitialTargetName;
static _str gInitialBuildSystem;
static _str gInitialBuildMakeFile;
static boolean gLeaveFileTabEnabled;
static _str gSaveComboList[]={
VPJ_SAVEOPTION_SAVENONE,
VPJ_SAVEOPTION_SAVECURRENT,
VPJ_SAVEOPTION_SAVEALL,
VPJ_SAVEOPTION_SAVEMODIFIED,
VPJ_SAVEOPTION_SAVEWORKSPACEFILES,
};
static _str gShowComboList[]={
VPJ_SHOWONMENU_ALWAYS,
VPJ_SHOWONMENU_HIDEIFNOCMDLINE,
VPJ_SHOWONMENU_NEVER,
};
#define PROJECTTREEADJUSTCOLUMNWIDTH 2600
#define JAVA_OPTS_DLG_DEF "_java_options_form Compiler"
#define GNUC_OPTS_DLG_DEF "_gnuc_options_form Compile"
#define VCPP_OPTS_DLG_DEF "_vcpp_options_form Compile"
static boolean gIsJavaConfigType;
static boolean gIsExtensionProject;
static boolean gUpdateTags;
static boolean gProjectFilesNotNeeded;
static boolean ignore_config_change;
// HS2-ADD: change working dir if user explicitely changed project working dir #1
static boolean use_projectdir_initially;
// If 1, ignore on_change events to _openfile_list:
static int gProjectIgnoreOnChange= 0;
static PROJECT_CONFIG_INFO gAllConfigsInfo;
_control _prjref_files;
_control ctlUserIncludesList;
_control ctlToolTree;
#define MIN_SPACE_BEFORE_PATH 200
static int gOrigProjectFileList;
#define MESSAGE_ALLCONFIG_TOOLS_MISMATCH "Select a configuration to view this command"
#define MESSAGE_PRESS_OPTIONS_BUTTON "<- Press Options button to view settings for this command"
static _str gSpecialToolMessage:[]=
{
#if 0
"javamake"=>"Compiles all out-of-date files using 'Compile' settings",
"javarebuild"=>"Recompiles all files using 'Compile' settings",
"javaviewdoc"=>"Updates javadoc and views javadoc for current file",
"javamakedoc"=>"Updates javadoc for all files using 'Javadoc' settings",
"javamakejar"=>"Updates Jar file using Jar program with all class files",
#endif
"javaoptions"=>"Displays dialog for setting options for Java tools",
"gnucoptions"=>"Displays dialog for setting options for GNU C/C++ tools",
"vcppoptions"=>"Displays dialog for setting options for Visual C++ Toolkit 2003"
};
void _project_refresh()
{
_tbSetRefreshBy(VSTBREFRESHBY_PROJECT);
//readAndParseAllExtensionProjects();
// Initialize the project tool table:
// We need this tool table initialized and consistent at all
// times to update the menubar's project menu.
if (_project_name!="") {
//readAndParseProjectToolList_ForAllConfigs();
//readAndParseProjectToolList(_project_name,"COMPILER."GetCurrentConfigName(),0,junk,0,junk2,gProjectInfo.ProjectSettings:[GetCurrentConfigName()].ToolInfo,gProjectInfo.ProjectSettings:[GetCurrentConfigName()].DirInfo);
//Just in case tag files for project were modified
_TagCallList(TAGFILE_ADD_REMOVE_CALLBACK_PREFIX,'','');
_TagCallList(TAGFILE_REFRESH_CALLBACK_PREFIX);
// Just in case there is an associated makefile
_MaybeRetagWorkspace(1,0);
// Just in case project files were modified
toolbarUpdateFilterList(_project_name);
} else if (_workspace_filename!='') {
toolbarUpdateFilterList(_project_name);
}
}
static void adjust_filespec(_str &vslickpathfilename)
{
#if !__UNIX__
_str comspec=get_env("COMSPEC")" /c";
if (file_eq(substr(vslickpathfilename,1,length(comspec)),comspec)) {
vslickpathfilename=strip(substr(vslickpathfilename,length(comspec)+1));
if (file_exists(vslickpathfilename".bat")) {
vslickpathfilename=vslickpathfilename".bat";
return;
}
if (file_exists(vslickpathfilename".cmd")) {
vslickpathfilename=vslickpathfilename".cmd";
return;
}
}
#endif
}
int _OnUpdate_project_edit(CMDUI &cmdui,int target_wid,_str command)
{
if (_project_name=='') {
if (_no_child_windows()) {
return(MF_GRAYED);
}
return(MF_ENABLED);
}
return(MF_ENABLED);
}
static void project_edit2(_str activetab="",_str ProjectFilename=_project_name)
{
//_macro_delete_line();
// No global project name==> No project opened!
if (ProjectFilename=='') {
int editorctl_wid=p_window_id;
if (!_isEditorCtl()) {
if (_no_child_windows()) {
_message_box(nls("There must be a window to set up extension specific project information."));
return;
}
editorctl_wid=_mdi.p_child;
}
show('-mdi -modal -xy _project_form','.'editorctl_wid.p_extension,gProjectExtHandle);
return;
}
typeless old_delay_filelist=def_delay_filelist;
def_delay_filelist=0;
mou_hour_glass(1);
//_convert_to_relative_project_file(_project_name);
typeless result=show('-mdi -modal -xy _project_form',ProjectFilename,_ProjectHandle(ProjectFilename),activetab);
mou_hour_glass(0);
def_delay_filelist=old_delay_filelist;
}
/**
* Allows you to add files to project, change project commands, working
* directory and other project properties. Displays Project Properties
* dialog box.
*
* @param activetab Index of tab to show on the Project Properties dialog. May also
* contain the absolute path to the project to open.
*
* @see project_add_file
* @see project_build
* @see project_rebuild
* @see project_debug
* @see project_execute
* @see project_user1
* @see project_user2
* @see workspace_open
* @see project_compile
* @see project_edit
* @see project_load
* @see new
* @see workspace_insert
* @see workspace_dependencies
* @see workspace_set_active
* @see workspace_properties
* @see workspace_close
* @see workspace_organize
*
* @categories Project_Functions
*
*/
_command void project_edit(_str activetab="") name_info(','VSARG2_REQUIRES_PROJECT_SUPPORT)
{
_str ProjectFilename='';
gProjectFilesNotNeeded=false;
parse activetab with activetab ProjectFilename;
// if no project name was specified and this was triggered from
// the project toolbar, infer the project name from the tree
if (ProjectFilename == "" && p_name==PROJECT_TOOLBAR_NAME) {
ProjectFilename=_projecttbTreeGetCurProjectName(-1,true);
//say('ProjectFilename='ProjectFilename);
_str olddir=getcwd();
chdir(strip_filename(ProjectFilename,'N'),1);
project_edit2(activetab,ProjectFilename);
chdir(olddir,1);
return;
}
if (file_exists(ProjectFilename)) {
project_edit2(activetab,ProjectFilename);
} else {
project_edit2(activetab);
}
}
static void _project_run_macro2(_str project_name = _project_name)
{
_str array[];
int handle=_ProjectHandle(project_name);
_ProjectGet_Macro(handle,array);
int i;
for (i=0;i= 0) {
targetName = lowcase(ctlToolTree._TreeGetCaption(ctlToolTree._TreeCurIndex()));
}
return targetName;
}
/**
* Get node for currently selected tool (target or rule)
*/
int GetTargetOrRuleNode(_str config = "")
{
int index = ctlToolTree._TreeCurIndex();
if(index < 0) return -1;
if(config == "") {
config = GetConfigText();
}
int node = -1;
// get parent target name and rule input exts
_str caption = ctlToolTree._TreeGetCaption(index);
// determine if this is a target or a rule
if(ctlToolTree._TreeGetDepth(index) == 2) {
// this is a rule
_str ruleSet = ctlToolTree._TreeGetCaption(ctlToolTree._TreeGetParentIndex(index));
node = _ProjectGet_RuleNode(gProjectHandle, ruleSet, caption, config);
} else {
// this is a target
node = _ProjectGet_TargetNode(gProjectHandle, caption, config);
}
return node;
}
_str GetCurrentConfigName(_str ProjectName=_project_name)
{
if (ProjectName=='') {
return('');
}
if (file_eq(ProjectName,_project_name) && gActiveConfigName!='') {
return(gActiveConfigName);
}
_str ConfigName='';
_ini_get_value(VSEWorkspaceStateFilename(), "ActiveConfig", _RelativeToWorkspace(ProjectName), ConfigName,'',_fpos_case);
parse ConfigName with ',' ConfigName;
if (ConfigName=='') {
//We have to just pick one...
_str List[];
_ProjectGet_ConfigNames(_ProjectHandle(ProjectName),List);
if (List._length()) {
ConfigName=List[0];
}
}
return(ConfigName);
}
void _workspace_opened_run_macros()
{
if (gWorkspaceHandle <= 0) {
return;
}
_str projectFiles[] = null;
_WorkspaceGet_ProjectFiles(gWorkspaceHandle, projectFiles);
int i;
for (i = 0; i < projectFiles._length(); i++) {
_str ProjectName = _AbsoluteToWorkspace(projectFiles[i]);
_project_run_macro2(ProjectName);
}
}
void _ProjectTemplateExpand(int templates_handle,int project_handle,boolean doSetAppType=false,boolean AddDefaultFilters=false)
{
int i;
typeless array[];
for (;;) {
// Look for CopyChildren
array._makeempty();
_xmlcfg_find_simple_array(project_handle,"//CopyChildren",array);
if (!array._length()) {
break;
}
for (i=0;i=0) {
_str AppType=_xmlcfg_get_attribute(project_handle,SetAppTypeNode,'AppType');
_xmlcfg_delete(project_handle,SetAppTypeNode);
_ProjectSetAppType(project_handle,AppType);
}
}
if (AddDefaultFilters) {
// Add file filters if necessary
int FilesNode=_ProjectGet_FilesNode(project_handle);
if (FilesNode<0) {
_ProjectAdd_DefaultFolders(project_handle);
}
}
}
////////////////////////////////////////////////////////////////////////////////
//11:03am 6/22/1999
//Adding some defaults so I can use this for the workspace stuff.
int workspace_new_project2(_str ProjectName='',
_str CompilerName='',
_str ExeName='',
_str WorkspaceName=_workspace_filename,
boolean ShowPropertiesDialog=true,
boolean SetWorkingDir=false,
_str AssociatedMakefile='',
_str AssociatedMakefileType='',
boolean RetagWorkspaceFiles=true,
ProjectConfig ConfigList[]=null,
boolean RemoveDirectoryIfCancelled=false,
boolean RemoveWorkspaceFileIfCancelled=false)
{
if (WorkspaceName=='') {
WorkspaceName=_workspace_filename;
}
if (WorkspaceName=='') {
_message_box('WorkspaceName must be specified');
return(1);
}
boolean operatingOnActiveWorkspace=_workspace_filename!='' && file_eq(_workspace_filename,WorkspaceName);
if (!_IsWorkspaceAssociated(WorkspaceName)) {
if (!operatingOnActiveWorkspace) {
_message_box('Invalid call to workspace_new_project(). Workspace must be active');
return(1);
}
}
_str result;
//compiler_name="";
if (ProjectName=='') {
result= show('-modal _project_new_form');
if (result=='') {
return(COMMAND_CANCELLED_RC);
}
if (_param2!='') {
CompilerName=_param2;
}
if (_param1!='') {
ExeName=_param1;
}
}else{
result=ProjectName;
}
//messageNwait("projectname="result" compiler_name="compiler_name);
// If there is an open project, close it:
_str new_project_name=absolute(strip(result));
// Create the project tag file
_str project_tag_filename=strip_filename(new_project_name,'E'):+TAG_FILE_EXT;
//tag_close_db(project_tag_filename);
//tag_create_db(project_tag_filename);
//tag_close_db(project_tag_filename);
_tbSetRefreshBy(VSTBREFRESHBY_PROJECT);
// Init the default project properties and show the properties form:
//name=slick_path_search(VSCFGFILE_PRJTEMPLATES);
_str initmacro='';
int project_handle=_ProjectCreateFromTemplate(new_project_name,CompilerName,initmacro,true,!_IsWorkspaceAssociated(WorkspaceName));
int ReleaseNode=_ProjectGet_ConfigNode(project_handle,'Release');
// This is only supported for Visual C++ and Tornado
int Node=0;
int j;
for (j=0;j tag OutputFile attributes
_xmlcfg_find_simple_array(project_handle, VPJX_CONFIG, array);
for(i = 0; i < array._length(); i++) {
_str outputFile = _xmlcfg_get_attribute(project_handle, array[i], "OutputFile");
outputFile = stranslate(outputFile, ExeName, "% 0) && (!isItemBold(index)) ) {
// handle special cases where this is the new entry node or the prev
// node is the new entry node
int prevIndex = _TreeGetPrevSiblingIndex(index);
if(prevIndex == -1) return;
if (isItemBold(prevIndex)) return;
// checking for bold should handle this
// if(strieq(_TreeGetCaption(index), BLANK_TREE_NODE_MSG)) return;
// if(strieq(_TreeGetCaption(prevIndex), BLANK_TREE_NODE_MSG)) return;
_TreeMoveUp(index);
// trigger the on_change event so that the data will be saved
switch(p_name) {
case 'ctlUserIncludesList':
ctlUserIncludesList.call_event(CHANGE_SELECTED,index,ctlUserIncludesList,ON_CHANGE, 'W');
break;
case 'ctlPreBuildCmdList':
ctlPreBuildCmdList.call_event(CHANGE_SELECTED,index,ctlPreBuildCmdList,ON_CHANGE, 'W');
break;
case 'ctlPostBuildCmdList':
ctlPostBuildCmdList.call_event(CHANGE_SELECTED,index,ctlPostBuildCmdList,ON_CHANGE, 'W');
break;
}
}
p_window_id = wid;
}
void ctlMoveUserIncludesDown.lbutton_up()
{
// find the tree control relative to the edit control
int wid = p_window_id;
p_window_id = wid.p_prev.p_prev.p_prev;
// with single node selection, if there is a current index, it is selected
int index = _TreeCurIndex();
if( (index > 0) && (!isItemBold(index)) ) {
// handle special cases where this is the new entry node or the next node
// is the new entry node
int nextIndex = _TreeGetNextSiblingIndex(index);
if(nextIndex == -1) return;
if (isItemBold(nextIndex)) return;
// checking for bold should handle this
// if(strieq(_TreeGetCaption(index), BLANK_TREE_NODE_MSG)) return;
// if(strieq(_TreeGetCaption(nextIndex), BLANK_TREE_NODE_MSG)) return;
_TreeMoveDown(index);
// trigger the on_change event so that the data will be saved
switch(p_name) {
case 'ctlUserIncludesList':
ctlUserIncludesList.call_event(CHANGE_SELECTED,index,ctlUserIncludesList,ON_CHANGE, 'W');
break;
case 'ctlPreBuildCmdList':
ctlPreBuildCmdList.call_event(CHANGE_SELECTED,index,ctlPreBuildCmdList,ON_CHANGE, 'W');
break;
case 'ctlPostBuildCmdList':
ctlPostBuildCmdList.call_event(CHANGE_SELECTED,index,ctlPostBuildCmdList,ON_CHANGE, 'W');
break;
}
}
p_window_id = wid;
}
typeless ctlUserIncludesList.on_change(int reason,int index)
{
if (gChangingConfiguration==1) {
// Force trees to update
ctlUserIncludesList._TreeRefresh();
ctlPreBuildCmdList._TreeRefresh();
ctlPostBuildCmdList._TreeRefresh();
ctlDefinesTree._TreeRefresh();
return 0;
}
// can not editor compiler include path directories
if(reason == CHANGE_EDIT_QUERY && isItemBold(index) &&
!strieq(arg(4), BLANK_TREE_NODE_MSG)) {
return -1;
}
if(reason == CHANGE_EDIT_OPEN) {
// if this is the new entry node, clear the message
if(strieq(arg(4), BLANK_TREE_NODE_MSG)) {
arg(4) = '';
} else if (isItemBold(index)) {
return -1;
}
typeless completion = (p_window_id == _control ctlUserIncludesList) ? DIR_ARG : NONE_ARG;
_post_call(_SetEditInPlaceCompletion, completion);
}
if(reason == CHANGE_EDIT_CLOSE) {
// check the old caption to see if it is the new entry node
_str caption = _TreeGetCaption(index);
boolean wasNewEntryNode = strieq(caption, BLANK_TREE_NODE_MSG);
// HS2-CHG: or if nth. was changed (e.g. by double clicking around)
// if the node changed and is now empty, delete it
if( (arg(4) == "") || strieq(arg(4), BLANK_TREE_NODE_MSG)) {
if(wasNewEntryNode) {
arg(4) = BLANK_TREE_NODE_MSG;
return 0;
} else {
_TreeDelete(index);
return DELETED_ELEMENT_RC;
}
}
// make sure the last node in the tree is the new entry node
if(wasNewEntryNode) {
// unbold the existing node
_TreeSetInfo(index, 0, -1, -1, 0);
// bold the new entry node
int newIndex = _TreeAddListItem(BLANK_TREE_NODE_MSG);
_TreeSetInfo(newIndex, 0, -1, -1, TREENODE_BOLD);
}
}
if (p_name:=='ctlDefinesTree') {
// the processing for the defines list is a bit more complicated than the others
UpdateProjectDefines();
} else if (ctlCurConfig.p_text==ALL_CONFIGS) {
int i;
for (i=0;i 0) {
// cannot delete new entry node
//if(strieq(_TreeGetCaption(index), BLANK_TREE_NODE_MSG)) {
if (isItemBold(index)) {
return;
}
_TreeDelete(index);
// HS2-ADD: trigger the on_change event so that the data will be saved
call_event(CHANGE_SELECTED,index,ctlUserIncludesList,ON_CHANGE, 'W');
}
}
void _checkDefine(_str &define)
{
_str ch1=substr(define,1,1);
_str ch2=upcase(substr(define,2,1));
// if no prefix
if ( ((ch1!='/')&&(ch1!='-')) ||
((ch2!='D')&&(ch2!='U')) ) {
// assume define
define='/D'define;
ch2='D';
}
// no reason to keep blank lines
if (length(strip(define))==2) {
define='';
} else {
// remove any space that might be between /D or /U and the macro
define=substr(define,1,2):+strip(substr(define,3));
// fix any problems with an equals sign, either missing, or unexpected
int equ_pos=0;
int spc_pos=0;
if (ch2=='D') {
equ_pos=pos('=',define);
spc_pos=pos(' ',define);
// if there are spaces AND
if ( (spc_pos!=0) &&
// no equals sign OR the first equals sign is after the first space
((equ_pos==0)||(equ_pos>spc_pos))) {
// replace the first space with an equals sign
define=substr(define,1,spc_pos-1):+'=':+substr(define,spc_pos+1);
}
} else { // ch2=='U'
// if there is a space or an equals sign, ignore everything after it
spc_pos=pos(' ',define);
if (spc_pos!=0) {
define=substr(define,1,spc_pos-1);
}
equ_pos=pos(' ',define);
if (equ_pos!=0) {
define=substr(define,1,equ_pos-1);
}
}
}
}
static boolean isMacroInList(_str check_define,_str list)
{
if (0==pos(check_define,list)) {
return false;
}
// the string appears in the list, now verify that is actually
// defined exactly the same way (pseudo match whole word)
while (list!='') {
_str define = parse_next_option(list,false);
if (define==check_define) {
return true;
}
}
return false;
}
static void maybeRemoveDefine(_str check_define,_str &list)
{
// get the name without the /D or /U
_str name='';
parse substr(check_define,3) with name '=' . ;
_str dname='';
_str orig_list=list;
list='';
while (orig_list!='') {
_str define = parse_next_option(orig_list,false);
parse substr(define,3) with dname '=' . ;
if (dname!=name) {
if (list!='') {
strappend(list,' ');
}
strappend(list,maybe_quote_filename(define));
}
}
}
static struct defchange {
boolean added;
_str define;
};
static _str fully_quote(_str input)
{
_str output='';
input=strip(input);
while (input!='') {
_str item=parse_next_option(input,false);
if (output:=='') {
output='"'item'"';
} else {
strappend(output,' "'item'"');
}
}
return output;
}
static void UpdateProjectDefines()
{
if (!p_EditInPlace) {
return;
}
_str defines='';
boolean hasDoubleClickLine=false;
// form a single string for the defines, all properly formatted
if (_TreeGetNumChildren(TREE_ROOT_INDEX)>0) {
int index = _TreeGetFirstChildIndex(TREE_ROOT_INDEX);
for (;index>=0;) {
_str someDefine=_TreeGetCaption(index);
if (someDefine:==BLANK_TREE_NODE_MSG) {
hasDoubleClickLine=true;
} else if (!isItemBold(index)) {
_checkDefine(someDefine);
if (someDefine!='') {
if (defines!='') {
strappend(defines,' ');
}
strappend(defines,'"'someDefine'"');
}
}
index=_TreeGetNextSiblingIndex(index);
}
}
if (ctlCurConfig.p_text==ALL_CONFIGS) {
if (defines!=gAllConfigsInfo.Defines) {
// they changed something, figure out what
defchange changes[];
_str orig=gAllConfigsInfo.Defines;
_str updated=defines;
_str define='';
int next_change=0;
// look for new defines
while (updated!='') {
define=parse_next_option(updated,false);
if (!isMacroInList(define,gAllConfigsInfo.Defines)) {
next_change=changes._length();
changes[next_change].added=true;
changes[next_change].define=define;
}
}
// now look for removed defines
while (orig!='') {
define=parse_next_option(orig,false);
if (!isMacroInList(define,defines)) {
next_change=changes._length();
changes[next_change].added=false;
changes[next_change].define=define;
}
}
// then apply the changes to all configs
int i,j;
for (i=0;i=0) {
_xmlcfg_delete(gProjectHandle,Node);
}
}
gAllConfigsInfo.TargetInfo._deleteel(lowcase(TargetName));
} else {
int Node = GetTargetOrRuleNode();
if (Node>=0) {
_xmlcfg_delete(gProjectHandle,Node);
}
}
// Delete the entry from the list box:
ctlToolTree._TreeDelete(ctlToolTree._TreeCurIndex());
ctlToolTree.call_event(CHANGE_SELECTED, ctlToolTree._TreeCurIndex(), ctlToolTree, ON_CHANGE, 'W');
ctlToolTree.refresh();
// Set ctlToolDelete.p_enabled and rebuild TargetList (could call SetTargetList() instead for this)
ctlCurConfig.call_event(CHANGE_SELECTED,ctlCurConfig,ON_CHANGE,'W');
}
void ctlAddDefine.lbutton_up()
{
_str prompt_title;
_str prompt_value;
_str prefix;
if (p_name=='ctlAddDefine') {
prompt_title='Enter the macro you wish to define';
prompt_value='name=value';
prefix='/D';
} else {
prompt_title='Enter the macro you wish to un-define';
prompt_value='name';
prefix='/U';
}
typeless result=show('-modal _textbox_form',
prompt_title,
0,//Flags,
'',//Tb width
'',//help item
'',//Buttons and captions
'',//retrieve name
'Macro:'prompt_value);
if (result=='') return;
_str macro=strip(_param1);
_str first_char=substr(macro,1,1);
if ((first_char!='/')&&(first_char!='-')) {
macro=prefix:+macro;
}
ctlDefinesTree._TreeBottom();
int lastIndex=ctlDefinesTree._TreeCurIndex(); // get the index of the =0) {
if (wid==ctlToolUp) {
PrevNode=_xmlcfg_get_prev_sibling(gProjectHandle,Node);
if (PrevNode!=-1) {
_xmlcfg_copy(gProjectHandle,Node,gProjectHandle,PrevNode,0);
_xmlcfg_delete(gProjectHandle,PrevNode);
}
} else {
NextNode=_xmlcfg_get_next_sibling(gProjectHandle,Node);
if (NextNode!=-1) {
_xmlcfg_copy(gProjectHandle,NextNode,gProjectHandle,Node,0);
_xmlcfg_delete(gProjectHandle,Node);
}
}
}
}
SetTargetList();
} else {
int Node = GetTargetOrRuleNode();
if (Node>=0) {
if (wid==ctlToolUp) {
PrevNode=_xmlcfg_get_prev_sibling(gProjectHandle,Node);
if (PrevNode!=-1) {
_xmlcfg_copy(gProjectHandle,Node,gProjectHandle,PrevNode,0);
_xmlcfg_delete(gProjectHandle,PrevNode);
}
} else {
NextNode=_xmlcfg_get_next_sibling(gProjectHandle,Node);
if (NextNode!=-1) {
_xmlcfg_copy(gProjectHandle,NextNode,gProjectHandle,Node,0);
_xmlcfg_delete(gProjectHandle,Node);
}
}
}
}
}
void ctlToolNew.lbutton_up()
{
// Prompt the user for a new tool name:
_str result;
result= show('-modal _textbox_form',
'New Project Tool', //Captions
0, //Flags
2000, //use default textbox width
'?Type a name for the new tool and press ENTER to add the tool.', //Help item
'', //Buttons and captions
'', //Retrieve Name
'New Tool Name:'//Prompt
);
//_param1= '' if someone presses ok on an empty box
if (result== '' || _param1== '') {
return;
}
//messageNwait("_param1="_param1);
_str name;
name= _param1;
name= strip(name); // strip any leading and trailing spaces
// Make sure that there are no colons or commas in tool name:
if (pos(":",name) || pos(",",name)) {
_message_box(nls("Tool name cannot contain ':' (colon) or ',' (comma)."));
return;
}
int status = ctlToolTree._TreeSearch(TREE_ROOT_INDEX, name, "I");
if(status >= 0) {
_message_box(nls("Tool '%s' already exists in project.",name));
return;
}
// create new tool and select it
int index = ctlToolTree._TreeAddItem(TREE_ROOT_INDEX, name, TREE_ADD_AS_CHILD, 0, 0, -1);
if (ctlCurConfig.p_text==ALL_CONFIGS) {
int i;
for (i=0;i
* This code always returns false if the cmdline is blank and there is a
* debugger callback for simplicity.
*
* @param projectToolList
* @param toolIndex
*
* @return
*/
static boolean captureOutputRequiresConcurrentProcess(_str TargetName,_str cmd)
{
if (strieq(TargetName,'debug') && _project_DebugCallbackName!='') {
int index=find_index('_'_project_DebugCallbackName'_DebugCommandCaptureOutputRequiresConcurrentProcess',PROC_TYPE);
if (index) {
boolean requireConcurrent=call_index(cmd,index);
if (!requireConcurrent) {
return(false);
}
}
return(true);
}
return(false);
}
static _str GetCaptureOutputWith()
{
_str CaptureOutputWith;
if (!ctlToolCaptureOutput.p_value) {
CaptureOutputWith='';
} else if (ctlToolOutputToConcur.p_value) {
CaptureOutputWith=VPJ_CAPTUREOUTPUTWITH_PROCESSBUFFER;
} else {
CaptureOutputWith=VPJ_CAPTUREOUTPUTWITH_REDIRECTION;
}
return(CaptureOutputWith);
}
void ctlToolCaptureOutput.lbutton_up()
{
_str TargetName=GetTargetName();
_str CmdLine='';
if (ctlCurConfig.p_text==ALL_CONFIGS) {
CmdLine=gAllConfigsInfo.TargetInfo:[lowcase(TargetName)].Exec_CmdLine;
}else{
CmdLine=ctlToolCmdLine.p_text;
}
if (CmdLine==null) {
CmdLine='';
}
ctlToolCaptureOutput.p_style=PSCH_AUTO2STATE;
// IF capture output is off
if (!p_value) {
ctlToolOutputToConcur.p_value=0;
ctlToolOutputToConcur.p_enabled= false;
ctlToolClearProcessBuf.p_value=0;
ctlToolClearProcessBuf.p_enabled= false;
#if __UNIX__
//ctlRunInXterm.p_value=0;
ctlRunInXterm.p_enabled= true;
//ctlRunInXterm.call_event(ctlRunInXterm,LBUTTON_UP,'W');
#endif
} else {
if (captureOutputRequiresConcurrentProcess(TargetName,CmdLine)) {
ctlToolOutputToConcur.p_value=1;
call_event(ctlToolOutputToConcur,LBUTTON_UP,'W');
//say('cmd='gProjectInfo2.ProjectSettings:[GetConfigText()].ToolInfo[toolIndex].cmd);
ctlToolOutputToConcur.p_enabled= false; //supportConcurrentProcessBuffer(projectToolList,toolIndex);
} else {
ctlToolOutputToConcur.p_value=0;
call_event(ctlToolOutputToConcur,LBUTTON_UP,'W');
//say('cmd='gProjectInfo2.ProjectSettings:[GetConfigText()].ToolInfo[toolIndex].cmd);
ctlToolOutputToConcur.p_enabled= true; //supportConcurrentProcessBuffer(projectToolList,toolIndex);
}
ctlToolClearProcessBuf.p_value=0;
//ctlToolClearProcessBuf.p_enabled= false;
#if __UNIX__
//ctlRunInXterm.p_value=0;
//ctlRunInXterm.p_enabled= false;
ctlRunInXterm.call_event(ctlRunInXterm,LBUTTON_UP,'W');
#endif
//If ctlToolOutputToConcur.p_value is false, this is supposed to be disabled - DWH
}
if (p_value!=ctlBuildFirst.p_value && ctlBuildFirst.p_value) {
ctlBuildFirst.p_value=p_value;
ctlBuildFirst.call_event(ctlBuildFirst,LBUTTON_UP,'W');
}
_str CaptureOutputWith=GetCaptureOutputWith();
//p_style=PSCH_AUTO2STATE;
if (ctlCurConfig.p_text==ALL_CONFIGS) {
int i;
for (i=0;i5) {
return; // wtf
}
_str SaveOption=gSaveComboList[option];
if (ctlCurConfig.p_text==ALL_CONFIGS) {
int i;
for (i=0;i5) {
return; // wtf
}
_str ShowOnMenu=gShowComboList[option];
if (ctlCurConfig.p_text==ALL_CONFIGS) {
int i;
for (i=0;i'Application - requires java.exe to run',
APPTYPE_APPLET=>'Applet - runs in a web browser',
APPTYPE_CUSTOM=>'Custom - command lines for execute and debug',
};
static _str _GetAppTypeListDescriptions(_str AppTypeList)
{
_str list=AppTypeList;
AppTypeList='';
for (;;) {
_str name='';
parse list with name','list;
if (name=='') {
return(AppTypeList);
}
name=_GetAppTypeName(name);
if (_AppTypeList_hashtab._indexin(name)) {
name=_AppTypeList_hashtab:[name];
}
if (AppTypeList=='') {
AppTypeList=name;
} else {
strappend(AppTypeList,','name);
}
}
}
static _str _GetAppTypeDescription(_str AppTypeList,_str AppType)
{
_str thisname=_GetAppTypeName(AppType);
_str list=AppTypeList;
for (;;) {
_str description='';
parse list with description','list;
if (description=='') {
return(thisname);
}
_str name=_GetAppTypeName(description);
if (strieq(name,thisname)) {
return(description);
}
}
}
void ctlAppType.on_change(int reason)
{
if (!ctlAppType.p_visible) return;
if (gChangingConfiguration==1) return;
_str AppType=_GetAppTypeName(p_text);
if (ctlCurConfig.p_text==ALL_CONFIGS) {
/*for (i=0;i1)?1:0;
// If not capturing output, disable output to process buffer and clear process
// buffer toggle buttons.
if (ctlToolCaptureOutput.p_value && ctlToolCaptureOutput.p_enabled) {
if (captureOutputRequiresConcurrentProcess(TargetName,(cmdLine==null)?'':cmdLine)) {
ctlToolOutputToConcur.p_enabled= false; //supportConcurrentProcessBuffer(projectToolList,toolIndex);
ctlToolOutputToConcur.p_value=1;
ctlToolOutputToConcur.call_event(ctlToolOutputToConcur,LBUTTON_UP,'W');
} else {
ctlToolOutputToConcur.p_enabled= true; //supportConcurrentProcessBuffer(projectToolList,toolIndex);
}
ctlToolClearProcessBuf.p_enabled= true;
//say('ctlToolClearProcessBuf.p_en='ctlToolClearProcessBuf.p_enabled);
#if __UNIX__
//This two commented out lines cause p_value to be set to zero when ctlToolCaptureOutput.p_value==2
//ctlRunInXterm.p_value= 0;
//ctlRunInXterm.call_event(ctlRunInXterm,LBUTTON_UP,'W');
//ctlRunInXterm.p_enabled= false;
#endif
} else {
ctlToolOutputToConcur.p_enabled= false;
ctlToolClearProcessBuf.p_enabled= false;
#if __UNIX__
ctlRunInXterm.p_enabled= true;
#endif
}
if (ctlToolOutputToConcur.p_value /*&& ctlToolOutputToConcur.p_enabled*/) {
ctlToolClearProcessBuf.p_enabled= true;
} else {
ctlToolClearProcessBuf.p_enabled= false;
ctlToolClearProcessBuf.p_value= 0;
}
if(Exec_Type == "" && !isRule) {
ctlToolCaptureOutput.p_enabled = 1;
} else {
ctlToolCaptureOutput.p_enabled = 0;
}
if (!ctlToolCaptureOutput.p_enabled && !ctlToolOutputToConcur.p_value) {
ctlBuildFirst.p_enabled=false;
} else {
switch (lowcase(TargetName)) {
case 'build':
case 'rebuild':
case 'compile':
case 'link':
ctlBuildFirst.p_enabled=false;
break;
default:
ctlBuildFirst.p_enabled=(EnableBuildFirst)?1:0;
// if 'Build' tool is a slickc macro, buildfirst cannot be enabled anywhere
if(!shouldEnableBuildFirst(gProjectHandle, GetConfigText())) {
ctlBuildFirst.p_enabled = false;
}
break;
}
}
if (BuildFirst==2) {
ctlBuildFirst.p_style=PSCH_AUTO3STATEB;
}
ctlBuildFirst.p_value= ctlBuildFirst.p_enabled ? BuildFirst : false;
// enable the save options combo based on the buildfirst enabled and value settings
if(isRule) {
ctlToolSaveCombo.p_enabled = 0;
} else if(ctlBuildFirst.p_enabled) {
ctlToolSaveCombo.p_enabled = !ctlBuildFirst.p_value;
} else {
ctlToolSaveCombo.p_enabled = 1;
}
gDialog='';
ctlcmdmessage.p_visible=false;
ctlToolCmdLine.p_ReadOnly=false;
ctlToolCmdLine.p_backcolor=0x80000005;
ctlCommandIsSlickCMacro.p_enabled=false;
if (Exec_Type==null) {
ctlCommandIsSlickCMacro.p_style=PSCH_AUTO3STATEB;
ctlCommandIsSlickCMacro.p_value=2;
} else {
ctlCommandIsSlickCMacro.p_style=PSCH_AUTO2STATE;
ctlCommandIsSlickCMacro.p_value=(Exec_Type!=null && strieq(Exec_Type,'Slick-C'))?1:0;
}
ctlRunFromDir.p_text = RunFromDir == null ? "" : RunFromDir;
if (Dialog==null || cmdLine==null) {
ctlToolCmdLine.p_visible=false;
ctlToolCmdLineButton.p_visible=false;
ctlBrowseCmdLine.p_visible=false;
ctlcommand_line_label.p_visible=false;
ctlcmdmessage.p_caption=MESSAGE_ALLCONFIG_TOOLS_MISMATCH;
ctlcmdmessage.p_visible=true;
ctlcommand_options.p_visible=0;
} else if (Dialog!='') {
ctlcommand_options.p_visible=1;
gDialog=Dialog;
ctlcommand_line_label.p_visible=0;
ctlToolCmdLine.p_visible=false;
ctlToolCmdLineButton.p_visible=false;
ctlBrowseCmdLine.p_visible=false;
ctlcommand_line_label.p_visible=false;
ctlcmdmessage.p_caption=MESSAGE_PRESS_OPTIONS_BUTTON;
ctlcmdmessage.p_visible=true;
}else{
ctlcommand_options.p_visible=0;
_str firstword='';
parse ctlToolCmdLine.p_text with firstword .;
_str *p;
p=gSpecialToolMessage._indexin(firstword);
if (p) {
ctlToolCmdLine.p_visible=false;
ctlToolCmdLineButton.p_visible=false;
ctlBrowseCmdLine.p_visible=false;
ctlcommand_line_label.p_visible=false;
ctlcmdmessage.p_caption=*p;
ctlcmdmessage.p_visible=true;
} else {
ctlToolCmdLine.p_visible=true;
ctlToolCmdLineButton.p_visible=true;
ctlBrowseCmdLine.p_visible=true;
ctlcommand_line_label.p_visible=1;
// cannot select IsSlickCMacro if a dialog is specified
ctlCommandIsSlickCMacro.p_enabled=true;
}
}
/*if (ctlToolCmdLine.p_ReadOnly) {
ctlToolCmdLine.p_backcolor=0x80000022;
} */
}
_str ctlcommand_options.lbutton_up(_str DialogName='')
{
if (DialogName=='') {
DialogName=gDialog;
}
_str Options='';
parse DialogName with DialogName Options;
int form_wid=p_active_form;
PROJECT_CONFIG_INFO ProjectInfo:[];
int wid=show('-hidden -wh 'DialogName,gProjectHandle,Options,GetConfigText(),gProjectName,gIsProjectTemplate);
//int wid=show('-hidden -wh 'DialogName,Options,&gAllConfigsInfo,gConfigList,GetConfigText(),gProjectName);
_str result='';
if (wid) {
//We do a modal wait on this dialog so that we can move the dialog over
//slightly
if (form_wid.p_visible) {
//If the form is not visible, this came up from the javaoptions command
//and we don't have to indent.
//wid.p_x+=500;
wid._show_entire_form();
}
wid.p_visible=true;
result=_modal_wait(wid);
if (result!='') {
form_wid.ctlCurConfig.call_event(CHANGE_SELECTED,form_wid.ctlCurConfig,ON_CHANGE,'W');
//SetIndirectCommands();
//ctlCurConfig.call_event(CHANGE_CLINE,ctlToolTree,ON_CHANGE,'W');
// trigger the on_change event so that the directory data that could have been
// changed in some options forms will be updated. the CHANGING_CONFIGURATION
// variable must be set here because the tree will attempt to save any changes
// that are made to its contents except during a configuration change.
//CHANGING_CONFIGURATION = 1;
//populateIncludesTrees();
//CHANGING_CONFIGURATION = 0;
}
}
return(result);
}
//-----------------------------------------------------------------------------------
void _opencancel.lbutton_up()
{
int fid= p_active_form;
//_save_form_response();
int value= _proj_prop_sstab.p_ActiveTab;
_append_retrieve( _proj_prop_sstab, value );
fid._delete_window('');
}
void _setMacroTextList(_str (&MacroCmdLines)[],int flags=EDC_INPUTINI)
{
_lbclear();
int i;
for (i=0;i=0) {
typeless folder_nodes[];
_xmlcfg_find_simple_array(gProjectHandle,VPJTAG_FOLDER,folder_nodes,files_node);
_str folder_name;
_str folder_filter;
int folder_index;
for (folder_index=0;folder_index=0) {
_xmlcfg_delete(gProjectHandle,files_node,true);
} else {
files_node=_ProjectGet_FilesNode(gProjectHandle,true);
}
if (filters_list:!='') {
// for easy parsing
_maybe_append(filters_list,',');
_str folder_name;
_str folder_filter;
int folder_node;
while (filters_list:!='') {
parse filters_list with folder_name '(' folder_filter '),' filters_list;
folder_node=_xmlcfg_add(gProjectHandle,
files_node,
'Folder',
VSXMLCFG_NODE_ELEMENT_START_END,
VSXMLCFG_ADD_AS_CHILD);
_xmlcfg_add_attribute(gProjectHandle,
folder_node,
'Name',
folder_name);
_xmlcfg_add_attribute(gProjectHandle,
folder_node,
'Filters',
folder_filter);
}
}
}
}
/**
* Displays the Project Properties dialog box. The project's
* values are updated before the dialog box is closed unless the user
* cancels the dialog box.
*
* @return Returns '' if the dialog box is cancelled. Otherwise, 1 is returned.
*
* @categories Forms
*
*/
void _ok.on_create(_str PropertiesForName='',int project_handle=-1,_str activetab='',boolean MakeCopyFirst=true,boolean doSaveIfNecessary=true,
boolean IsProjectPackage=false)
{
if (project_handle<0) {
return;
}
gUpdateTags=false;
gLeaveFileTabEnabled=true;
gOrigProjectFileList= 0;
//gWildCardFileAttributesHashTab._makeempty();
gSetActiveConfigTo='';
gInitialTargetName= _retrieve_value("_project_form.toolNameSelected");
gFileListModified=0; // List is not modified.
gIsJavaConfigType=false;
gAllConfigsInfo._makeempty();
gProjectHandle=project_handle;
gMakeCopyFirst=MakeCopyFirst;
gdoSaveIfNecessary=doSaveIfNecessary;
gIsProjectTemplate=IsProjectPackage;
gConfigName=PropertiesForName; // Only used when editing settings for extension project
gIsExtensionProject=(project_handle==gProjectExtHandle);
ignore_config_change=false;
gOrigProjectHandle=project_handle;
if (gMakeCopyFirst) {
gProjectHandle=_xmlcfg_create(_xmlcfg_get_filename(project_handle),VSENCODING_UTF8);
_xmlcfg_copy(gProjectHandle,TREE_ROOT_INDEX,project_handle,TREE_ROOT_INDEX,VSXMLCFG_COPY_CHILDREN);
}
gProjectName=PropertiesForName;
if (!gIsProjectTemplate) {
gProjectName=_xmlcfg_get_filename(project_handle);
}
_xmlcfg_set_modify(gProjectHandle,0);
_ProjectGet_ConfigNames(gProjectHandle,gConfigList);
gInitialBuildSystem = _ProjectGet_BuildSystem(gProjectHandle);
gInitialBuildMakeFile = _ProjectGet_BuildMakeFile(gProjectHandle);
if (!gIsExtensionProject && !gIsProjectTemplate) {
//_ini_get_value(_project_name,"ASSOCIATION",'makefile',makefile,'');
//_ini_get_value(_project_name,"ASSOCIATION",'makefiletype',makefiletype,'');
_GetAssociatedProjectInfo(gProjectName,gAssociatedFile,gAssociatedFileType);
}
#if __UNIX__
ctlRunInXterm.p_visible= true;
#endif
// Fill in the options for the modified files save combo box
ctlToolSaveCombo.p_cb_list_box._lbadd_item("Save none"); // SAVENONE=0
ctlToolSaveCombo.p_cb_list_box._lbadd_item("Save current file"); // SAVECURRENT=1
ctlToolSaveCombo.p_cb_list_box._lbadd_item("Save all files"); // SAVEALL=2
ctlToolSaveCombo.p_cb_list_box._lbadd_item("List modified files"); // SAVEMODIFIED=3
ctlToolSaveCombo.p_cb_list_box._lbadd_item("Save workspace files"); // SAVEWORKSPACEFILES=4
//ctlToolSaveCombo.p_cb_list_box._lbadd_item(""); // SAVENONUNIFORMOPTIONS=5
// fill in the options for the hide combo box
ctlToolHideCombo.p_cb_list_box._lbadd_item("Always show on menu"); // HIDENEVER=0
ctlToolHideCombo.p_cb_list_box._lbadd_item("Hide if no command line"); // HIDEEMPTY=1
ctlToolHideCombo.p_cb_list_box._lbadd_item("Never show on menu"); // HIDEALWAYS=2
// If a real project is opened, _project_name is not "" and arg(1)== ""
// If an extension project is opened, _project_name is "" and arg(1) is ".e" or ".c" or ...
int fid=p_active_form;
_str SectionsList[];
if (gIsProjectTemplate) {
p_active_form.p_caption='Project Package for "'PropertiesForName'"';
} else if(gIsExtensionProject) {
p_active_form.p_caption='Project Properties For 'PropertiesForName;
} else {
p_active_form.p_caption="Project Properties For ":+GetProjectDisplayName(PropertiesForName);
}
// Disable unused tabs (for extension project):
//
//_proj_prop_sstab._setEnabled(PROJPROPTAB_CONFIGURATIONS,0); // Configurations
if (gIsExtensionProject) { // extension project or project pack
ctlRunFromDir.p_enabled=false;
_proj_prop_sstab._setEnabled(PROJPROPTAB_FILES,0); // Files tab
_proj_prop_sstab._setEnabled(PROJPROPTAB_DIRECTORIES,1);
_proj_prop_sstab._setEnabled(PROJPROPTAB_BUILDOPTS,0); // Build Options tab
_proj_prop_sstab._setEnabled(PROJPROPTAB_OPENCOMMAND,0); // Command
// Make sure the active tab is one of the enabled ones:
if (activetab=='') {
activetab= _retrieve_value("_project_form._proj_prop_sstab");
}
if (activetab== PROJPROPTAB_FILES
|| activetab== PROJPROPTAB_BUILDOPTS
|| activetab== PROJPROPTAB_OPENCOMMAND
/*|| activetab== PROJPROPTAB_CONFIGURATIONS*/) {
_proj_prop_sstab.p_ActiveTab= PROJPROPTAB_DIRECTORIES;
} else if (activetab!=''){
_proj_prop_sstab.p_ActiveTab= (int)activetab;
}
// For a project pack, get the pack information from arg(2).
ctlPreBuildCmdList.DisableAll();
ctlCurConfig.p_enabled=false;
ctlCurConfig.p_prev.p_enabled=false;
ctlconfigurations.p_enabled=false;
} else if (gIsProjectTemplate) {
_proj_prop_sstab._setEnabled(PROJPROPTAB_FILES,0); // Files tab
// Make sure the active tab is one of the enabled ones:
if (activetab=='') {
activetab= _retrieve_value("_project_form._proj_prop_sstab");
}
if (activetab== PROJPROPTAB_FILES) {
_proj_prop_sstab.p_ActiveTab= PROJPROPTAB_DIRECTORIES;
} else if (activetab!=''){
_proj_prop_sstab.p_ActiveTab= (int)activetab;
}
ctlfolders.p_visible=true;
} else { // real project
// Restore active tab:
if (activetab=='') {
activetab= _retrieve_value("_project_form._proj_prop_sstab");
}
if (activetab!=''){
_proj_prop_sstab.p_ActiveTab= (int)activetab;
}
}
//if (file_eq(get_extension(_workspace_filename,1),VCPP_PROJECT_WORKSPACE_EXT)) {
if (!gIsExtensionProject && !gIsProjectTemplate) { // a real project opened
if (_IsWorkspaceAssociated(_workspace_filename)) {
// if the association does not support modifying the file list, disable
// the files tab
boolean LeaveFileTabEnabled=_CanWriteFileSection(GetProjectDisplayName(gProjectName));
gLeaveFileTabEnabled=LeaveFileTabEnabled;
DisableProjectControlsForWorkspace(LeaveFileTabEnabled, false);
if (!gProjectFilesNotNeeded && !_IsEclipseWorkspaceFilename(_workspace_filename) &&
!_IsJBuilderAssociatedWorkspace(_workspace_filename)) {
int modify=_xmlcfg_get_modify(gProjectHandle);
int Node=_ProjectGet_FilesNode(gProjectHandle,true);
int temp_view_id;
int orig_view_id;
get_window_id(orig_view_id);
int status=GetProjectFiles(gProjectName, temp_view_id,'',null,'',true,true,false);
_str path=strip_filename(gProjectName,'N');
if (!status) {
int flags=VSXMLCFG_ADD_AS_CHILD;
activate_window(temp_view_id);
for (;;) {
if (down()) {
break;
}
_str filename='';
get_line(filename);
Node=_xmlcfg_add(gProjectHandle,Node,VPJTAG_F,VSXMLCFG_NODE_ELEMENT_START_END,flags);
_xmlcfg_set_attribute(gProjectHandle,Node,'N',_NormalizeFile(relative(filename,path)));
flags=0;
}
_delete_temp_view(temp_view_id);
}
activate_window(orig_view_id);
_xmlcfg_set_modify(gProjectHandle,modify);
} else if(_IsJBuilderAssociatedWorkspace(_workspace_filename)) {
int associatedHandle = _ProjectGet_AssociatedHandle(gProjectHandle);
int FilesNode=_ProjectGet_FilesNode(gProjectHandle,true);
_str path = strip_filename(gProjectName, "N");
typeless nodeArray[] = null;
_xmlcfg_find_simple_array(associatedHandle, "/project//" VPJTAG_F, nodeArray);
int i;
for(i = 0; i < nodeArray._length(); i++) {
_str filename = _xmlcfg_get_attribute(associatedHandle, nodeArray[i], "N");
// only wildcards in jbuilder are for directory views which cannot be deleted
if(iswildcard(filename)) continue;
int Node=_xmlcfg_add(gProjectHandle,FilesNode,VPJTAG_F,VSXMLCFG_NODE_ELEMENT_START_END,VSXMLCFG_ADD_AS_CHILD);
_xmlcfg_set_attribute(gProjectHandle,Node,'N',_NormalizeFile(relative(filename,path)));
}
}
} else {
_prjref_files.p_prev.p_enabled=false; // references label
_prjref_files.p_enabled=false;
_prjref_files.p_next.p_enabled=false; // browse button
_prjref_files.p_next.p_next.p_enabled=false; // menu button
}
}
// Initialize the various tabs:
// If an extension project is being opened, only the Directories, Tools, and
// Compile Options tabs need to be initialized.
if (!gIsExtensionProject) { // a real project opened
oncreateMacro();
}
// Initialize the Directories and Tools tabs.
// project ==> ".e" for extension project, "" for real project
oncreateDirectories();
oncreateBuildOptions();
// load dependencies tab with all projects in workspace except this one
if (!gIsExtensionProject && !gIsProjectTemplate) { // a real project opened
oncreateDependencies();
}
if (gIsExtensionProject) {
//gConfigList._makeempty();
//gConfigList[0]=gConfigName;
ctlCurConfig.p_text= gConfigName;
//gConfigList[0]=_ProjectGet_ConfigNode(handle,gConfigName,true);
} else {
//_ProjectGet_Configs(gProjectName,gConfigList);
ctlCurConfig.p_cb_list_box._lbclear();
int i;
for (i=0;icmd parameter
*/
static _str _ProjectReplaceOther(_str cmd,_str other)
{
int p=pos('(^|[~%])\%\~other',cmd,1,'r');
_str cmd2='';
if (p) {
if (p>1) {
cmd2=substr(cmd,1,p);
++p;
}
//7 is the length of %~other
cmd2=cmd2:+other:+substr(cmd,p+7);
}else cmd2=cmd;
return(cmd2);
}
#endif
static void populate_config_list(_str type = '')
{
gChangingConfiguration=1;
ctlCompilerList.p_cb_list_box._lbclear();
ctlCompilerList.p_text = '';
gChangingConfiguration=0;
if (type :!= "java") {
ctlCompilerList.p_cb_list_box._lbadd_item(COMPILER_NAME_LATEST' ('_GetLatestCompiler()')');
if (def_refactor_active_config != '') {
ctlCompilerList.p_cb_list_box._lbadd_item(COMPILER_NAME_DEFAULT' ('def_refactor_active_config')');
} else {
ctlCompilerList.p_cb_list_box._lbadd_item(COMPILER_NAME_DEFAULT' (none selected)');
}
} else {
ctlCompilerList.p_cb_list_box._lbadd_item(COMPILER_NAME_LATEST' ('_GetLatestJDK()')');
if (def_active_java_config!= '') {
ctlCompilerList.p_cb_list_box._lbadd_item(COMPILER_NAME_DEFAULT' ('def_active_java_config')');
} else {
ctlCompilerList.p_cb_list_box._lbadd_item(COMPILER_NAME_DEFAULT' (none selected)');
}
}
_str compiler_name='';
// sometimes have to open compilers.xml again here because _GetLatestXXX will close it
_str filename=_config_path():+COMPILER_CONFIG_FILENAME;
if (!refactor_config_is_open(filename)){
refactor_config_open(filename);
}
int i,n = refactor_config_count();
for (i=0; i= 0) {
// if the project index was not specified, infer it from the config node
if(projectIndex < 0) {
projectIndex = ctlDepsTree._TreeGetParentIndex(configIndex);
}
// get the tree information for the project and config
int projectState = 0, configState = 0;
ctlDepsTree._TreeGetInfo(projectIndex, projectState);
ctlDepsTree._TreeGetInfo(configIndex, configState);
if(configChecked) {
// check the config
ctlDepsTree._TreeSetInfo(configIndex, configState, _pic_treecb_checked, _pic_treecb_checked);
// graycheck the project
ctlDepsTree._TreeSetInfo(projectIndex, projectState, _pic_treecb_graychecked, _pic_treecb_graychecked);
// make sure the implied config is not graychecked
int impliedConfigIndex = ctlDepsTree._TreeSearch(projectIndex, curConfig, "I");
if(impliedConfigIndex >= 0) {
int impliedConfigState = 0, impliedConfigPic;
ctlDepsTree._TreeGetInfo(impliedConfigIndex, impliedConfigState, impliedConfigPic);
if(impliedConfigPic == _pic_treecb_graychecked) {
ctlDepsTree._TreeSetInfo(impliedConfigIndex, impliedConfigState, _pic_treecb_unchecked, _pic_treecb_unchecked);
}
}
} else {
// uncheck the config
ctlDepsTree._TreeSetInfo(configIndex, configState, _pic_treecb_unchecked, _pic_treecb_unchecked);
// ungraycheck the project if no other configs are checked
boolean uncheckProject = true;
int siblingConfigState = 0;
int siblingConfigIndex = ctlDepsTree._TreeGetFirstChildIndex(projectIndex);
int siblingConfigPic;
while(siblingConfigIndex >= 0) {
// get the config information in the tree
ctlDepsTree._TreeGetInfo(siblingConfigIndex, siblingConfigState, siblingConfigPic);
if(siblingConfigPic == _pic_treecb_checked) {
uncheckProject = false;
break;
}
// next config
siblingConfigIndex = ctlDepsTree._TreeGetNextSiblingIndex(siblingConfigIndex);
}
// ungraycheck the project if necessary
if(uncheckProject) {
ctlDepsTree._TreeSetInfo(projectIndex, projectState, _pic_treecb_unchecked, _pic_treecb_unchecked);
}
}
} else if(projectIndex >= 0) {
// get the tree information for the project
int projectState = 0;
ctlDepsTree._TreeGetInfo(projectIndex, projectState);
if(projectChecked) {
// check the project
ctlDepsTree._TreeSetInfo(projectIndex, projectState, _pic_treecb_checked, _pic_treecb_checked);
// graycheck the config that matches the current config
int defConfigIndex = ctlDepsTree._TreeSearch(projectIndex, curConfig, "I");
if(defConfigIndex >= 0) {
int defConfigState = 0;
// get the bitmap information in the tree
ctlDepsTree._TreeGetInfo(defConfigIndex, defConfigState);
// graycheck the config
ctlDepsTree._TreeSetInfo(defConfigIndex, defConfigState, _pic_treecb_graychecked, _pic_treecb_graychecked);
}
} else {
// uncheck the project
ctlDepsTree._TreeSetInfo(projectIndex, projectState, _pic_treecb_unchecked, _pic_treecb_unchecked);
// if a project was unchecked, uncheck all configurations underneath it
int configState = 0;
configIndex = ctlDepsTree._TreeGetFirstChildIndex(projectIndex);
while(configIndex >= 0) {
// get the bitmap information in the tree
ctlDepsTree._TreeGetInfo(configIndex, configState);
// uncheck the picture
ctlDepsTree._TreeSetInfo(configIndex, configState, _pic_treecb_unchecked, _pic_treecb_unchecked);
// next config
configIndex = ctlDepsTree._TreeGetNextSiblingIndex(configIndex);
}
}
}
}
static void updateDependenciesProjectInfo(_str curConfig, _str depProject, _str depConfig,
boolean checked, boolean wasGraychecked)
{
// if a config was clicked, depConfig will not be empty
if(depConfig != "") {
if(checked) {
// make sure there is no longer a project level dependency
_ProjectRemove_Dependency(gProjectHandle, depProject, "", "", curConfig, false);
// add the config level dependency
_ProjectAdd_Dependency(gProjectHandle, depProject, depConfig, "", curConfig);
// update the DependsRef attribute for build, rebuild, clean targets
updateDependsRefs(curConfig, true);
} else if(wasGraychecked) {
// this is the implied config level dependency and therefore
// the project level dependency should be removed instead
_ProjectRemove_Dependency(gProjectHandle, depProject, "", "", curConfig, false);
// update the DependsRef attribute for build, rebuild, clean targets
updateDependsRefs(curConfig, false);
} else {
// remove the dependency
_ProjectRemove_Dependency(gProjectHandle, depProject, depConfig, "", curConfig, depConfig == "");
// update the DependsRef attribute for build, rebuild, clean targets
updateDependsRefs(curConfig, false);
}
} else if(checked) {
// add the project level dependency
_ProjectAdd_Dependency(gProjectHandle, depProject, depConfig, "", curConfig);
// update the DependsRef attribute for build, rebuild, clean targets
updateDependsRefs(curConfig, true);
} else {
// remove the project or config level dependency
_ProjectRemove_Dependency(gProjectHandle, depProject, depConfig, "", curConfig, depConfig == "");
// update the DependsRef attribute for build, rebuild, clean targets
updateDependsRefs(curConfig, false);
}
}
/**
* Update the DependsRef attributes of the Build, Rebuild, and Clean
* targets in the specified config.
*/
static void updateDependsRefs(_str config, boolean enable)
{
// look for a dependencies node for the specified configuration. this
// will be checked when enable is false because the DependsRef attribute
// should only be removed if there are no dependencies.
int dependenciesNode = _ProjectGet_DependenciesNode(gProjectHandle, config);
// look for build target
int buildTargetNode = _ProjectGet_TargetNode(gProjectHandle, "Build", config);
if(buildTargetNode >= 0) {
if(enable) {
_ProjectSet_TargetDependsRef(gProjectHandle, buildTargetNode, config);
} else if(dependenciesNode < 0) {
// enable is false and there is no dependencies set, so clear the DependsRef
_ProjectSet_TargetDependsRef(gProjectHandle, buildTargetNode, "");
}
}
// look for rebuild target
int rebuildTargetNode = _ProjectGet_TargetNode(gProjectHandle, "Rebuild", config);
if(rebuildTargetNode >= 0) {
if(enable) {
_ProjectSet_TargetDependsRef(gProjectHandle, rebuildTargetNode, config);
} else if(dependenciesNode < 0) {
// enable is false and there is no dependencies set, so clear the DependsRef
_ProjectSet_TargetDependsRef(gProjectHandle, rebuildTargetNode, "");
}
}
// look for clean target
int cleanTargetNode = _ProjectGet_TargetNode(gProjectHandle, "Clean", config);
if(cleanTargetNode >= 0) {
if(enable) {
_ProjectSet_TargetDependsRef(gProjectHandle, cleanTargetNode, config);
} else if(dependenciesNode < 0) {
// enable is false and there is no dependencies set, so clear the DependsRef
_ProjectSet_TargetDependsRef(gProjectHandle, cleanTargetNode, "");
}
}
}
static void clearDependenciesTree()
{
// iterate over projects unchecking everything
int index = ctlDepsTree._TreeGetFirstChildIndex(TREE_ROOT_INDEX);
while(index >= 0) {
// get the bitmap information in the tree
int state=0;
ctlDepsTree._TreeGetInfo(index, state);
// uncheck the project
ctlDepsTree._TreeSetInfo(index, state, _pic_treecb_unchecked, _pic_treecb_unchecked);
// process all configs
int childIndex = ctlDepsTree._TreeGetFirstChildIndex(index);
while(childIndex >= 0) {
// get the bitmap information in the tree
ctlDepsTree._TreeGetInfo(childIndex, state);
// uncheck the config
ctlDepsTree._TreeSetInfo(childIndex, state, _pic_treecb_unchecked, _pic_treecb_unchecked);
// next config
childIndex = ctlDepsTree._TreeGetNextSiblingIndex(childIndex);
}
// next project
index = ctlDepsTree._TreeGetNextSiblingIndex(index);
}
}
static void findAndCheckDependency(_str depProject, _str depConfig)
{
// determine whether tree search will be case-sensitive or not
_str searchOptions = "";
#if __UNIX__
#else
searchOptions = "I";
#endif
// find it in the tree
int depIndex = ctlDepsTree._TreeSearch(TREE_ROOT_INDEX, depProject, searchOptions);
if(depIndex >= 0) {
// now check to see if specific config was specified
if(depConfig != "") {
// find it in the tree
int depConfigIndex = ctlDepsTree._TreeSearch(depIndex, depConfig, "I");
if(depConfigIndex >= 0) {
// graycheck the project and check the config
updateDependenciesTreeInfo(GetConfigText(), depIndex, false, depConfigIndex, true);
} else {
// check the project
updateDependenciesTreeInfo(GetConfigText(), depIndex, true);
}
} else {
// check the project
updateDependenciesTreeInfo(GetConfigText(), depIndex, true);
}
}
}
static void resetDependenciesTreeFromNodeList(int (&dependencyNodes)[] = null)
{
int state = 0;
// uncheck everything in the dependencies tree
clearDependenciesTree();
// check the dependent project/configs
int i, n = dependencyNodes._length();
for(i = 0; i < n; i++) {
int depNode = dependencyNodes[i];
if(depNode < 0) continue;
_str depProject = _xmlcfg_get_attribute(gProjectHandle, depNode, "Project");
_str depConfig = _xmlcfg_get_attribute(gProjectHandle, depNode, "Config");
if(depProject == "") {
continue;
}
// make depProject relative to the workspace instead of this project
depProject = _AbsoluteToProject(depProject, gProjectName);
depProject = _RelativeToWorkspace(depProject);
// check this dependency
findAndCheckDependency(depProject, depConfig);
}
}
static void resetDependenciesTreeFromAllConfigs(PROJECT_DEPENDENCY_INFO (&dependencyValues):[] = null)
{
int state = 0;
// uncheck everything in the dependencies tree
clearDependenciesTree();
// check the dependent project/configs
typeless d;
for(d._makeempty();;) {
dependencyValues._nextel(d);
if(d._isempty()) break;
_str depProject = dependencyValues:[d].Project;
_str depConfig = dependencyValues:[d].Config;
if(depProject == "") {
continue;
}
// make depProject relative to the workspace instead of this project
depProject = _AbsoluteToProject(depProject, gProjectName);
depProject = _RelativeToWorkspace(depProject);
// check this dependency
findAndCheckDependency(depProject, depConfig);
}
}
static int okDependencies()
{
// determine whether tree search will be case-sensitive or not
_str searchOptions = "";
#if __UNIX__
#else
searchOptions = "I";
#endif
// run thru the dependencies and make sure that all project level
// dependencies have configs that match the implied config names
//
// NOTE: this is done by running thru the xml file instead of the
// tree because the tree only displays the representation
// of a single configuration (or the 'all configs' combined
// case). the tree is only used to determine what configs
// a project has in order to avoid having to open all of
// the workspace projects again.
int c;
for(c = 0; c < gConfigList._length(); c++) {
_str config = gConfigList[c];
// get all dependencies for this config
int dependencyNodes[] = null;
_ProjectGet_DependencyProjectNodes(gProjectHandle, dependencyNodes, config);
// only need to check project level dependencies
int i;
for(i = 0; i < dependencyNodes._length(); i++) {
int depNode = dependencyNodes[i];
if(depNode < 0) continue;
_str depProject = _xmlcfg_get_attribute(gProjectHandle, depNode, "Project");
_str depConfig = _xmlcfg_get_attribute(gProjectHandle, depNode, "Config");
// if depConfig is not empty, this is a config level dependency
// and does not need to be checked
if(depConfig != "") continue;
// find depProject in the dependencies tree
int depProjectIndex = ctlDepsTree._TreeSearch(TREE_ROOT_INDEX, depProject, searchOptions);
if(depProjectIndex >= 0) {
// now check to see if this project has the current config
int depConfigIndex = ctlDepsTree._TreeSearch(depProjectIndex, config, "I");
if(depConfigIndex < 0) {
// config not found so switch to the dependencies tab
_proj_prop_sstab.p_ActiveTab = PROJECTPROPERTIES_TABINDEX_DEPENDENCIES;
// highlight the project in question and expand it
ctlDepsTree._TreeSetCurIndex(depProjectIndex);
int state, pic;
ctlDepsTree._TreeGetInfo(depProjectIndex, state, pic);
ctlDepsTree._TreeSetInfo(depProjectIndex, 1, pic, pic);
// notify the user that there is a problem
_message_box("The project '" depProject "' does not have a '" config "' configuration. In order to specify a dependency\ron a project, one of the following criteria must be satisfied:\r\r - There must be a matching configuration.\r\r - A specific configuration must be selected.");
// return an error so the project properties dialog will not close
return -1;
}
}
}
}
return 0;
}
static void fillInDefines(_str defines, _str lockedDefines)
{
int newIndex;
ctlDefinesTree._TreeDelete(TREE_ROOT_INDEX,'C');
_str cur_def='';
while (lockedDefines!='') {
cur_def=parse_next_option(lockedDefines,false);
newIndex=ctlDefinesTree._TreeAddItem(TREE_ROOT_INDEX,cur_def,TREE_ADD_AS_CHILD,0,0,-1);
ctlDefinesTree._TreeSetInfo(newIndex,0,-1,-1,TREENODE_BOLD);
}
while (defines!='') {
cur_def=parse_next_option(defines,false);
ctlDefinesTree._TreeAddItem(TREE_ROOT_INDEX,cur_def,TREE_ADD_AS_CHILD,0,0,-1);
}
if (ctlDefinesTree.p_EditInPlace && ctlDefinesTree.p_enabled) {
// add the node for new data
newIndex = ctlDefinesTree._TreeAddListItem(BLANK_TREE_NODE_MSG);
ctlDefinesTree._TreeSetInfo(newIndex, 0, -1, -1, TREENODE_BOLD);
}
}
static _str allConfigsDefines(_str all_defines,_str cur_defines)
{
_str init_defines=all_defines;
all_defines='';
while ((init_defines!='')&&(cur_defines!='')) {
_str test_define=parse_next_option(init_defines,false);
if (pos(test_define,cur_defines)) {
if (all_defines!='') {
strappend(all_defines,' ');
}
strappend(all_defines, '"'test_define'"');
}
}
return all_defines;
}
void _ProjectGet_AllConfigsInfo(int handle,PROJECT_CONFIG_INFO &info,_str (&ConfigList)[]=null)
{
info=null;
ConfigList._makeempty();
int array[] = null;
_ProjectGet_Configs(handle,array);
int i;
for (i=0;iMenuCaption,pt->MenuCaption)) pt->MenuCaption='';
if (!strieq(pt2->OutputExts,pt->OutputExts)) pt->OutputExts='';
if (!strieq(pt2->LinkObject,pt->LinkObject)) pt->LinkObject=2;
if (!strieq(pt2->BuildFirst,pt->BuildFirst)) pt->BuildFirst=2;
if (!strieq(pt2->Verbose,pt->Verbose)) pt->Verbose=2;
if (!strieq(pt2->Beep,pt->Beep)) pt->Beep=2;
if (!strieq(pt2->Dialog,pt->Dialog)) pt->Dialog='';
if (!strieq(pt2->Deletable,pt->Deletable)) pt->Deletable=2;
if (!strieq(pt2->ShowOnMenu,pt->ShowOnMenu)) pt->ShowOnMenu='';
if (!strieq(pt2->EnableBuildFirst,pt->EnableBuildFirst)) pt->EnableBuildFirst=2;
if (pt->CaptureOutputWith!=null && !strieq(pt2->CaptureOutputWith,pt->CaptureOutputWith)) pt->CaptureOutputWith=null;
if (!strieq(pt2->ClearProcessBuffer,pt->ClearProcessBuffer)) pt->ClearProcessBuffer=2;
if (!strieq(pt2->RunInXterm,pt->RunInXterm)) pt->RunInXterm=2;
if (!strieq(pt2->PreMacro,pt->PreMacro)) pt->PreMacro=2;
if (!strieq(pt2->RunFromDir,pt->RunFromDir)) pt->RunFromDir="";
if (!strieq(pt2->AppletClass,pt->AppletClass)) pt->AppletClass='';
if (pt->Exec_CmdLine!=null && !strieq(pt2->Exec_CmdLine,pt->Exec_CmdLine)) pt->Exec_CmdLine=null;
if (pt->Exec_Type!=null && !strieq(pt2->Exec_Type,pt->Exec_Type)) pt->Exec_Type=null;
if (!strieq(pt2->Exec_OtherOptions,pt->Exec_OtherOptions)) pt->Exec_OtherOptions='';
// check rules for each target
typeless k;
for(k._makeempty();;) {
PROJECT_RULE_INFO* pr2 = &pt2->Rules._nextel(k);
if(k._isempty()) break;
PROJECT_RULE_INFO* pr = pt->Rules._indexin(k);
if(!pr) {
// not in pr, so add it
pt->Rules:[k] = *pr2;
pr = &pt->Rules:[k];
}
if(!strieq(pr2->InputExts,pr->InputExts)) pr->InputExts='';
if(!strieq(pr2->OutputExts,pr->OutputExts)) pr->OutputExts='';
if(!strieq(pr2->LinkObject,pr->LinkObject)) pr->LinkObject=2;
if(!strieq(pr2->Dialog,pr->Dialog)) pr->Dialog='';
if(!strieq(pr2->Deletable,pr->Deletable)) pr->Deletable=2;
if(!strieq(pr2->RunFromDir,pr->RunFromDir)) pr->RunFromDir="";
if(pr->Exec_CmdLine!=null && !strieq(pr2->Exec_CmdLine,pr->Exec_CmdLine)) pr->Exec_CmdLine=null;
if(pr->Exec_Type!=null && !strieq(pr2->Exec_Type,pr->Exec_Type)) pr->Exec_Type=null;
if(!strieq(pr2->Exec_OtherOptions,pr->Exec_OtherOptions)) pr->Exec_OtherOptions='';
}
}
// look for dependencies that do not match
typeless d;
for(d._makeempty();;) {
// get each dependency from info
PROJECT_DEPENDENCY_INFO* pd = &info.DependencyInfo._nextel(d);
if(d._isempty()) break;
// check to see if that dependency is also in info2
PROJECT_DEPENDENCY_INFO* pd2 = info2.DependencyInfo._indexin(d);
if(!pd2) {
// not in info2 so remove it from the all configs case
info.DependencyInfo:[d] = null;
continue;
}
// no need to validate the dependency attributes because the
// key (variable d above) is project/config/target which covers
// all of the values already
}
}
}
void ctlCurConfig.on_change(int reason)
{
if (ignore_config_change) {
return;
}
gChangingConfiguration=1;
/*if (!p_active_form.p_visible && p_text!=ALL_CONFIGS) {
CHANGING_CONFIGURATION=0;
return;
} */
_str ConfigName=GetConfigText();
ctlToolUp.p_enabled=ctlToolDown.p_enabled=ctlToolAdvanced.p_enabled=1;
_str ToolName=GetTargetName();
if (ToolName=='') {
ToolName=lowcase(gInitialTargetName);
}
gIsJavaConfigType=true;
//ctlAppType.p_text must be set before we call the on_change event for ctlToolTree
_str AppType;
_str AppTypeList;
if (ctlCurConfig.p_text==ALL_CONFIGS) {
_ProjectGet_AllConfigsInfo(gProjectHandle,gAllConfigsInfo,gConfigList);
// do not allow them to edit includes for all configurations unless they match
ctlIncDirLabel.p_enabled=gAllConfigsInfo.IncludesMatchForAllConfigs;
ctlBrowseUserIncludes.p_enabled=gAllConfigsInfo.IncludesMatchForAllConfigs; // browse button
ctlMoveUserIncludesUp.p_enabled=gAllConfigsInfo.IncludesMatchForAllConfigs; // up button
ctlMoveUserIncludesDown.p_enabled=gAllConfigsInfo.IncludesMatchForAllConfigs; // down button
ctlUserIncludesList.p_enabled=gAllConfigsInfo.IncludesMatchForAllConfigs;
ctlUserIncludesList.p_EditInPlace=gAllConfigsInfo.IncludesMatchForAllConfigs;
if (!gAllConfigsInfo.IncludesMatchForAllConfigs) {
ctlUserIncludesList._TreeSetDelimitedItemList(gAllConfigsInfo.Includes, PATHSEP, false,
"Select a configuration to edit includes");
}
//_prjworking_dir.p_text= AllDirInfo.WorkingDir;
if(!strieq(gAllConfigsInfo.Type,'java') && ctlUserIncludesList.p_EditInPlace) {
gIsJavaConfigType=false;
ctlUserIncludesList._TreeSetDelimitedItemList(gAllConfigsInfo.Includes, PATHSEP, false,
_ProjectGet_AssociatedIncludes(gProjectHandle, false));
}
//
_prjref_files.p_text= gAllConfigsInfo.RefFile;
ctlPreBuildCmdList._TreeSetDelimitedItemList(gAllConfigsInfo.PreBuildCommands, "\1", true);
ctlPostBuildCmdList._TreeSetDelimitedItemList(gAllConfigsInfo.PostBuildCommands, "\1", true);
ctlStopOnPreErrors.p_style=(gAllConfigsInfo.StopOnPreBuildError==2)?PSCH_AUTO3STATEB:PSCH_AUTO2STATE;
ctlStopOnPreErrors.p_value = gAllConfigsInfo.StopOnPreBuildError;
ctlStopOnPostErrors.p_style=(gAllConfigsInfo.StopOnPostBuildError==2)?PSCH_AUTO3STATEB:PSCH_AUTO2STATE;
ctlStopOnPostErrors.p_value = gAllConfigsInfo.StopOnPostBuildError;
AppTypeList=gAllConfigsInfo.AppTypeList;
AppType=gAllConfigsInfo.AppType;
// update the compiler config name to match what appears in the compilers list
if (gAllConfigsInfo.CompilerConfigName:==COMPILER_NAME_LATEST) {
// Latest is always listed first in the list
ctlCompilerList.p_cb_list_box._lbtop();
gAllConfigsInfo.CompilerConfigName=ctlCompilerList.p_cb_list_box._lbget_text();
} else if (gAllConfigsInfo.CompilerConfigName:==COMPILER_NAME_DEFAULT) {
// Default is always listed second
ctlCompilerList.p_cb_list_box._lbtop();
ctlCompilerList.p_cb_list_box._lbdown();
gAllConfigsInfo.CompilerConfigName=ctlCompilerList.p_cb_list_box._lbget_text();
}
ctlCompilerList.p_text = gAllConfigsInfo.CompilerConfigName;
ctlCompilerList.p_cb_list_box._lbsearch(gAllConfigsInfo.CompilerConfigName);
ctlCompilerList.p_cb_list_box._lbselect_line();
fillInDefines(gAllConfigsInfo.Defines,gAllConfigsInfo.AssociatedDefines);
ctlLibraries.p_text=gAllConfigsInfo.Libs;
ctlToolTree._TreeDelete(TREE_ROOT_INDEX, "C");
if (gAllConfigsInfo.TargetList!=null) {
_str list=gAllConfigsInfo.TargetList;
for (;;) {
_str item='';
parse list with item "\1" list;
if (item=="") {
break;
}
_str lowcasedItem = lowcase(item);
// only add + if there are rules for this target
if(!gAllConfigsInfo.TargetInfo:[lowcasedItem].Rules._isempty()) {
// add the target
int targetIndex = ctlToolTree._TreeAddItem(TREE_ROOT_INDEX, item, TREE_ADD_AS_CHILD, 0, 0, 1);
// add rules as children
typeless r;
for(r._makeempty();;) {
gAllConfigsInfo.TargetInfo:[lowcasedItem].Rules._nextel(r);
if(r._isempty()) break;
ctlToolTree._TreeAddItem(targetIndex, gAllConfigsInfo.TargetInfo:[lowcasedItem].Rules:[r].InputExts, TREE_ADD_AS_CHILD, 0, 0, -1);
}
} else {
// add the target
ctlToolTree._TreeAddItem(TREE_ROOT_INDEX, item, TREE_ADD_AS_CHILD, 0, 0, -1);
}
}
} else {
// Since all the tools are not the same, we can't change the menu order. User must
// pick a specific configuration.
ctlToolUp.p_enabled=ctlToolDown.p_enabled=0;
typeless i;
for (i._makeempty();;) {
gAllConfigsInfo.TargetInfo._nextel(i);
if (i._isempty()) break;
// only add + if there are rules for this target
if(!gAllConfigsInfo.TargetInfo:[i].Rules._isempty()) {
// add the target
int targetIndex = ctlToolTree._TreeAddItem(TREE_ROOT_INDEX, gAllConfigsInfo.TargetInfo:[i].Name, TREE_ADD_AS_CHILD, 0, 0, 1);
// add rules as children
typeless r;
for(r._makeempty();;) {
gAllConfigsInfo.TargetInfo:[i].Rules._nextel(r);
if(r._isempty()) break;
ctlToolTree._TreeAddItem(targetIndex, gAllConfigsInfo.TargetInfo:[i].Rules:[r].InputExts, TREE_ADD_AS_CHILD, 0, 0, -1);
}
// sort the rules
ctlToolTree._TreeSortCaption(targetIndex);
} else {
// add the target
ctlToolTree._TreeAddItem(TREE_ROOT_INDEX, gAllConfigsInfo.TargetInfo:[i].Name, TREE_ADD_AS_CHILD, 0, 0, -1);
}
}
ctlToolTree._TreeSortCaption(TREE_ROOT_INDEX);
}
// update dependencies
resetDependenciesTreeFromAllConfigs(gAllConfigsInfo.DependencyInfo);
}else{
if (gIsExtensionProject && _ProjectGet_ConfigNode(gProjectHandle,ConfigName)<0) {
// copy the (none) template
_str initmacro='';
int temp_handle=_ProjectCreateFromTemplate('','(generic)',initmacro,true,false);
int Node=_ProjectGet_ConfigNode(temp_handle,'Release');
if (Node<0) {
_str array[];
_ProjectGet_ConfigNames(temp_handle,array);
Node=_ProjectGet_ConfigNode(temp_handle,array[0]);
}
int ProjectNode=_xmlcfg_set_path(gProjectHandle,"/"VPJTAG_PROJECT);
_xmlcfg_copy(gProjectHandle,ProjectNode,temp_handle,Node,VSXMLCFG_COPY_AS_CHILD);
_xmlcfg_close(temp_handle);
_xmlcfg_set_attribute(gProjectHandle,_xmlcfg_get_last_child(gProjectHandle,ProjectNode),'Name',ConfigName);
_xmlcfg_set_modify(gProjectHandle,0);
// gProjectHandle is now an ext-specific project so find the doctype
// and change the dtd location
int doctypeNode = _xmlcfg_get_first_child(gProjectHandle, TREE_ROOT_INDEX, VSXMLCFG_NODE_DOCTYPE);
while(doctypeNode >= 0) {
// check the name
if(_xmlcfg_get_name(gProjectHandle, doctypeNode) == "DOCTYPE") {
// change the SYTEM attribute
_xmlcfg_set_attribute(gProjectHandle, doctypeNode, "SYSTEM", VPE_DTD_PATH);
break;
}
// step next
doctypeNode = _xmlcfg_get_next_sibling(gProjectHandle, doctypeNode);
}
}
_str compiler_name=_ProjectGet_CompilerConfigName(gProjectHandle,ConfigName);
if(!strieq(_ProjectGet_Type(gProjectHandle,ConfigName),'java')) {
gIsJavaConfigType=false;
ctlIncDirLabel.p_enabled=true;
ctlBrowseUserIncludes.p_enabled=true; // browse button
ctlMoveUserIncludesUp.p_enabled=true; // up button
ctlMoveUserIncludesDown.p_enabled=true; // down button
ctlUserIncludesList.p_enabled=true;
ctlUserIncludesList.p_EditInPlace=true;
ctlUserIncludesList._TreeSetDelimitedItemList(_ProjectGet_IncludesList(gProjectHandle, ConfigName),
PATHSEP, false,
_ProjectGet_AssociatedIncludes(gProjectHandle, false, ConfigName));
}
_prjref_files.p_text= _ProjectGet_RefFile(gProjectHandle,ConfigName);
ctlPreBuildCmdList._TreeSetDelimitedItemList(_ProjectGet_PreBuildCommandsList(gProjectHandle,ConfigName), "\1", true);
ctlPostBuildCmdList._TreeSetDelimitedItemList(_ProjectGet_PostBuildCommandsList(gProjectHandle,ConfigName), "\1", true);
ctlStopOnPreErrors.p_style=PSCH_AUTO2STATE;
ctlStopOnPreErrors.p_value = (int)_ProjectGet_StopOnPreBuildError(gProjectHandle,ConfigName);
ctlStopOnPostErrors.p_style=PSCH_AUTO2STATE;
ctlStopOnPostErrors.p_value = (int) _ProjectGet_StopOnPostBuildError(gProjectHandle,ConfigName);
AppType= _ProjectGet_AppType(gProjectHandle,ConfigName);
AppTypeList= _ProjectGet_AppTypeList(gProjectHandle,ConfigName);
// change the compiler name to match what is in the compiler list
if (compiler_name:==COMPILER_NAME_LATEST) {
// latest is always at the top of the list
ctlCompilerList.p_cb_list_box._lbtop();
compiler_name=ctlCompilerList.p_cb_list_box._lbget_text();
} else if (compiler_name:==COMPILER_NAME_DEFAULT) {
// default is always second in the list
ctlCompilerList.p_cb_list_box._lbtop();
ctlCompilerList.p_cb_list_box._lbdown();
compiler_name=ctlCompilerList.p_cb_list_box._lbget_text();
}
ctlCompilerList.p_text = compiler_name;
ctlCompilerList.p_cb_list_box._lbsearch(compiler_name);
ctlCompilerList.p_cb_list_box._lbselect_line();
_str assoc_file = _ProjectGet_AssociatedFile(gProjectHandle);
if (assoc_file!='') {
fillInDefines(_ProjectGet_Defines(gProjectHandle,ConfigName),_ProjectGet_AssociatedDefines('',gProjectHandle,ConfigName,assoc_file,false));
} else {
fillInDefines(_ProjectGet_Defines(gProjectHandle,ConfigName),'');
}
ctlLibraries.p_text=_ProjectGet_DisplayLibsList(gProjectHandle,ConfigName);
_str array[];
_ProjectGet_Targets(gProjectHandle,array,ConfigName);
ctlToolTree._TreeDelete(TREE_ROOT_INDEX, "C");
int i;
for (i=0;i 0) {
// add the target
int targetIndex = ctlToolTree._TreeAddItem(TREE_ROOT_INDEX, item, TREE_ADD_AS_CHILD, 0, 0, 1);
// add rules as children
int ruleIndex;
for(ruleIndex = 0; ruleIndex < rulesArray._length(); ruleIndex++) {
ctlToolTree._TreeAddItem(targetIndex, _ProjectGet_TargetInputExts(gProjectHandle, rulesArray[ruleIndex]), TREE_ADD_AS_CHILD, 0, 0, -1);
}
} else {
// add the target
ctlToolTree._TreeAddItem(TREE_ROOT_INDEX, item, TREE_ADD_AS_CHILD, 0, 0, -1);
}
}
// update dependencies
int dependencyNodes[] = null;
_ProjectGet_DependencyProjectNodesForRef(gProjectHandle, ConfigName, ConfigName, dependencyNodes);
resetDependenciesTreeFromNodeList(dependencyNodes);
}
if (gIsJavaConfigType) {
ctlIncDirLabel.p_enabled=0;
ctlDefinesLabel.p_enabled=0;
ctlDefinesTree.p_EditInPlace=0;
ctlDefinesTree.p_enabled=0;
ctlAddDefine.p_enabled=0;
ctlAddUndef.p_enabled=0;
ctlUserIncludesList.p_enabled=0;
ctlUserIncludesList.p_next.p_enabled=0; // browse button
ctlMoveUserIncludesUp.p_enabled=0; // up button
ctlMoveUserIncludesDown.p_enabled=0; // down button
//ctlCompilerList.p_enabled=0;
ctlBuild_vsbuild.p_visible=0;
ctlBuild_AutoMakefile.p_visible=0;
ctlBuild_Custom.p_visible=0;
ctlBuildDescription.p_visible=0;
ctlMakefileLabel.p_visible=0;
ctlAutoMakefile.p_visible=0;
ctlAutoMakefileButton.p_visible=0;
ctlBuildSystem.p_visible=0;
ctllabel4.p_enabled=0;
ctlLibraries.p_enabled=0;
ctlLinkOrder.p_enabled=0;
ctlLibrariesButton.p_enabled=0;
} else {
ctlBuild_vsbuild.p_visible=1;
ctlBuild_AutoMakefile.p_visible=1;
ctlBuild_Custom.p_visible=1;
ctlBuildDescription.p_visible=1;
ctlMakefileLabel.p_visible=1;
ctlAutoMakefile.p_visible=1;
ctlAutoMakefileButton.p_visible=1;
ctlBuildSystem.p_visible=1;
}
int status = ctlToolTree._TreeSearch(TREE_ROOT_INDEX, ToolName, "I");
if(status >= 0) {
ctlToolTree._TreeSetCurIndex(status);
} else {
// not found so default to first in list
ctlToolTree._TreeSetCurIndex(0);
}
ctlToolTree._TreeSelectLine(ctlToolTree._TreeCurIndex());
if (AppTypeList!='') {
//If this is not a hash table, this project just does not have any
//application type info
//
//Now set the ctlAppType combo box to the appropriate value
int wid=p_window_id;
p_window_id=ctlAppType.p_cb_list_box;
//Try to get the combo box's list box on the right line
_lbclear();
ctlAppType.FillInAppTypes(AppTypeList);
_lbtop();
_lbsearch(AppType);
p_window_id=wid;
ctlAppType.p_text=_GetAppTypeDescription(AppTypeList,AppType);
ctlAppType.p_visible=ctlAppTypeLabel.p_visible=true;
} else {
ctlHelpLabelTools.p_visible=true;
ctlAppType.p_visible=ctlAppTypeLabel.p_visible=false;
}
_srcfile_list.FillInSrcFileList(ctlCurConfig.p_text);
ctlToolTree.call_event(CHANGE_SELECTED, ctlToolTree._TreeCurIndex(), ctlToolTree, ON_CHANGE, 'W');
ctlToolTree.refresh();
gChangingConfiguration=0;
}
// HS2-ADD: change working dir if user explicitely changed project working dir #3
void _prjworking_dir.on_change()
{
use_projectdir_initially = true;
}
void _prjref_files.on_change()
{
if (gChangingConfiguration==1) return;
if (ctlCurConfig.p_text==ALL_CONFIGS) {
int i;
for (i=0;i 0) {
// get the bitmap information in the tree
int pic, state, arrayIndex;
_TreeGetInfo(index, state, pic);
arrayIndex = _TreeGetUserInfo(index);
// note whether this is a config or a project. if it is a config,
// it will be a leaf node (state == -1). otherwise, it is a project.
boolean isProject = (state != -1);
boolean isConfig = (state == -1);
// toggle the picture, remembering if it was enabled or not so the
// value can be set in the project
boolean checked = false;
if(pic == _pic_treecb_checked || pic == _pic_treecb_graychecked) {
checked = false;
} else {
checked = true;
}
if(isProject) {
// update the project and potentially graycheck the implied config
updateDependenciesTreeInfo(GetConfigText(), index, checked);
} else if(isConfig) {
// update the config and potentially graycheck the parent project
updateDependenciesTreeInfo(GetConfigText(), -1, false, index, checked);
}
// get the names of the project (and config if applicable)
_str depProject = "", depConfig = "";
if(isProject) {
depProject = _TreeGetCaption(index);
} else {
depProject = _TreeGetCaption(_TreeGetParentIndex(index));
depConfig = _TreeGetCaption(index);
}
// now store the information in the project
if(ctlCurConfig.p_text == ALL_CONFIGS) {
int i;
for(i = 0; i < gConfigList._length(); i++) {
_str config = gConfigList[i];
// set the value in each config in the project
updateDependenciesProjectInfo(config, depProject, depConfig, checked, pic == _pic_treecb_graychecked);
// update the values in the all configs hash table
if(checked) {
PROJECT_DEPENDENCY_INFO* pd = &gAllConfigsInfo.DependencyInfo:[lowcase(depProject "/" depConfig "/" /*depTarget*/)];
pd->Project = depProject;
pd->Config = depConfig;
} else {
gAllConfigsInfo.DependencyInfo:[lowcase(depProject "/" depConfig "/" /*depTarget*/)] = null;
}
}
} else {
// set the value in the current config in the project
updateDependenciesProjectInfo(GetConfigText(), depProject, depConfig, checked, pic == _pic_treecb_graychecked);
}
}
return 0;
}
static void DisableProjectControlsForWorkspace(boolean LeaveFileTabEnabled=false,
boolean LeaveDepsTabEnabled=true)
{
_add.DisableAll();
_srcfile_list.p_enabled=1;//Want users to be able to scroll through files
if (LeaveFileTabEnabled) {
_add.p_enabled=1;
_addtree.p_enabled=1;
_invert.p_enabled=1;
ctlrefresh.p_enabled=1;
_remove.p_enabled=1;
_remove_all.p_enabled=1;
ctlproperties.p_enabled=1;
ctlUserIncludesList.p_enabled=true;
_project_nofselected.p_enabled=true;
_project_nofselected.p_prev.p_enabled=true;
ctlCompilerList.p_enabled=true;
}
_prjworklab.p_enabled=false;
_prjworking_dir.p_enabled=false;
_prjworking_dir.p_next.p_enabled=false; // browse button
//_prjref_files.p_prev.p_enabled=false; // references label
//_prjref_files.p_enabled=false;
//_prjref_files.p_next.p_enabled=false; // browse button
//_prjref_files.p_next.p_next.p_enabled=false; // menu button
ctlIncDirLabel.p_enabled=true;
ctlBrowseUserIncludes.p_enabled=true; // browse button
ctlMoveUserIncludesUp.p_enabled=true; // up button
ctlMoveUserIncludesDown.p_enabled=true; // down button
ctlUserIncludesList.p_EditInPlace=true;
ctlDefinesLabel.p_enabled=true;
ctlDefinesTree.p_EditInPlace=true;
ctlAddDefine.p_enabled=true;
ctlAddUndef.p_enabled=true;
ctlCaptureOutputFrame.p_enabled=true;
ctlToolCaptureOutput.p_enabled=true;
ctlToolOutputToConcur.p_enabled=true;
ctlToolClearProcessBuf.p_enabled=true;
ctlRunFromDir.p_enabled=true;
ctlHelpLabelDir.p_enabled=true;
// Disable all the Build tab controls (this requires removing the
// nodes from the trees)
ctlPreBuildCmdList._TreeDelete(TREE_ROOT_INDEX, 'C');
ctlPostBuildCmdList._TreeDelete(TREE_ROOT_INDEX, 'C');
ctlPreBuildCmdList.DisableAll();
if(!LeaveDepsTabEnabled) {
ctlDepsTree.p_enabled = 0;
}
}
static void DisableAll()
{
int origwid=p_window_id;
int wid=origwid;
for (;;) {
wid=wid.p_next;
wid.p_enabled=0;
if (wid.p_object==OI_FRAME) {
int child=wid.p_child;
if (child) {
child.DisableAll();
}
}
if (wid==origwid) {
break;
}
}
}
_ok.on_destroy()
{
//if (!sstIsControlExists("_openchange_dir")) return( "" );
if (gOrigProjectFileList) {
_delete_temp_view(gOrigProjectFileList);
}
if (gMakeCopyFirst) {
_xmlcfg_close(gProjectHandle);
}
_append_retrieve(0, ctlToolTree._TreeGetCaption(ctlToolTree._TreeCurIndex()), "_project_form.toolNameSelected");
}
static void _InitAddFileToConfig(int (&FileToNode):[],int &FilesNode,_str &AutoFolders,int (&ExtToNodeHashTab):[],_str &LastExt,int &LastNode)
{
LastExt=null;
LastNode= -1;
_ProjectGet_FileToNodeHashTab(gProjectHandle,FileToNode);
FilesNode=_ProjectGet_FilesNode(gProjectHandle,true);
AutoFolders=_ProjectGet_AutoFolders(gProjectHandle);
_ProjectGet_ExtToNode(gProjectHandle,ExtToNodeHashTab);
}
/**
* Adds file to the file view for the specified
* configuration. If the file will now be in all
* configurations, it is added to the
* "All Configurations" view and removed from the others.
*
* @param Filename Filename to add
*
* @param ConfigName Name of configuration to add the file to
*
* @param SortBuffer If true(default), the buffer is sorted when done.
*/
static void AddFileToConfig(int list_wid,_str Filename,_str ConfigName,
int (&FileToNode):[]=null,
int FilesNode=-1,_str AutoFolders=null,int (&ExtToNodeHashTab):[]=null,
_str &LastExt=null,
int &LastNode= -1,
WILDCARD_FILE_ATTRIBUTES attrs=null
)
{
list_wid._lbadd_item(Filename);
gFileListModified=1;
_str cfilename=_file_case(Filename);
if (FileToNode==null) {
_InitAddFileToConfig(FileToNode,FilesNode,AutoFolders,ExtToNodeHashTab,LastExt,LastNode);
}
int *pnode=FileToNode._indexin(cfilename);
int Node=0;
if (pnode) {
Node=*pnode;
} else {
if (strieq(AutoFolders,VPJ_AUTOFOLDERS_CUSTOMVIEW)) {
_ProjectAdd_FilteredFiles(gProjectHandle,Filename,FileToNode,ExtToNodeHashTab,LastExt,LastNode);
} else {
_str list[];
list[0]=Filename;
_ProjectAdd_Files(gProjectHandle,list,FileToNode,FilesNode,AutoFolders,ExtToNodeHashTab,false);
}
Node=FileToNode:[cfilename];
}
if (ConfigName==ALL_CONFIGS) {
_xmlcfg_delete_attribute(gProjectHandle,Node,'C');
} else {
_str configs=_xmlcfg_get_attribute(gProjectHandle,Node,'C');
int i;
i=pos(always_quote_filename(ConfigName),configs);
if (!i) {
configs=strip(configs' 'always_quote_filename(ConfigName));
_str temp=configs;
// Check if this file contains all configs
int count;
for (count=0;temp!='';++count) {
parse temp with '"' . '"' temp;
}
if (count>=gConfigList._length()) {
_xmlcfg_delete_attribute(gProjectHandle,Node,'C');
} else {
_xmlcfg_set_attribute(gProjectHandle,Node,'C',configs);
}
}
}
if (attrs!=null) {
_xmlcfg_set_attribute(gProjectHandle,Node,'Recurse',attrs.Recurse);
_xmlcfg_set_attribute(gProjectHandle,Node,'Refilter',attrs.Refilter);
_xmlcfg_set_attribute(gProjectHandle,Node,'Excludes',_NormalizeFile(attrs.Excludes));
}
}
/**
* Add all files under the specified tree node to the provided
* hash table. This function is called by the open file dialog
* callback that is used with the Project Properties dialog
* and the Files tab of the Project Toolbar.
*
* @param treeID ID of the tree control that contains the node
* @param index The index of the node to add
* @param hashTable Hash table to add files to
*/
static void addFilesToHashFromTree(int treeID, int index, boolean (&hashTable):[])
{
if(index < 0) {
return;
}
// make sure it is a file (ignore projects, folders, dependent projects, etc)
if(treeID._projecttbIsProjectFileNode(index)) {
// extract the absolute filename from the tree caption
_str caption = treeID._TreeGetCaption(index);
_str filename = "";
_str absoluteFilename = "";
parse caption with filename "\t" absoluteFilename;
// add to the hash table
hashTable:[_file_case(absoluteFilename)] = true;
}
int childIndex = treeID._TreeGetFirstChildIndex(index);
while(childIndex >= 0) {
addFilesToHashFromTree(treeID, childIndex, hashTable);
// move next
childIndex = treeID._TreeGetNextSiblingIndex(childIndex);
}
}
static boolean projectPropertiesAddFileHash:[] = null;
/**
* This is the callback that is called for each item before it
* is included on the Open dialog that is shown when the user
* clicks Add Files on the Files tab of the Project Properties
* dialog.
*
* IMPORTANT: This function must *only* be called while the
* Project Properties dialog is open, unless this
* is the init case (filename == "")
*
* @param filename
*
* @return
*/
int projectPropertiesAddFilesCallback(_str filename = "")
{
// if def_show_prjfiles_in_open_dlg is 1 then this callback has
// been globally disabled by the user
if(def_show_prjfiles_in_open_dlg == 1) return 1;
// if filename is empty, clean the cached information
if(filename == "") {
projectPropertiesAddFileHash._makeempty();
return 0;
}
// default to including it
int includeItem = 1;
// if the file hash is empty, this is the first time the callback has
// been called for this open dialog. populate it with all the files
// in the current config of the project
if(projectPropertiesAddFileHash._isempty()) {
// add known extensions that should be ignored
// (workspace, project, history, tag files)
//
// NOTE: this serves two purposes
// 1. make hash lookups on ignored extensions possible
// 2. make sure the hash table is not empty even if the project is empty
projectPropertiesAddFileHash:[_file_case(WORKSPACE_FILE_EXT)] = true;
projectPropertiesAddFileHash:[_file_case(WORKSPACE_STATE_FILE_EXT)] = true;
projectPropertiesAddFileHash:[_file_case(PRJ_FILE_EXT)] = true;
projectPropertiesAddFileHash:[_file_case(TAG_FILE_EXT)] = true;
// figure out which dialog the open dialog was launched from
boolean fromProjectProperties = false;
boolean fromProjectToolbar = false;
// search the ancestry all the way to the top
int origid = p_window_id;
int wid = p_window_id;
for(;;) {
if(strieq(wid.p_name, "_project_form")) {
fromProjectProperties = true;
break;
} else if(strieq(wid.p_name, "_tbprojects_form")) {
fromProjectToolbar = true;
break;
}
// move up another level
if(!wid.p_parent) break;
wid = wid.p_parent;
}
p_window_id = wid;
if(fromProjectProperties) {
// the file list has already been processed, so just iterate thru
// the source list box to save time
_srcfile_list._lbtop();
_srcfile_list._lbup();
while(!_srcfile_list._lbdown()) {
// make the file absolute so later lookups do not have to be done relatively
_str absoluteFilename = _AbsoluteToProject(_srcfile_list._lbget_text(), gProjectName);
projectPropertiesAddFileHash:[_file_case(absoluteFilename)] = true;
}
// check to see if the open dialog was launched from the project toolbar
} else if(fromProjectToolbar) {
_nocheck _control _proj_tooltab_tree;
// the file list has already been processed and wildcards have
// been expanded in the project toolbar, so iterate thru the
// tree to save time
// find project that is the parent of the selected node
int projectNode = _proj_tooltab_tree._TreeCurIndex();
while(_proj_tooltab_tree._TreeGetDepth(projectNode) > 1) {
projectNode = _proj_tooltab_tree._TreeGetParentIndex(projectNode);
}
// recursively walk the tree
addFilesToHashFromTree(_proj_tooltab_tree, projectNode, projectPropertiesAddFileHash);
}
// restore window id
p_window_id = origid;
}
// check to see if the file is in the hash table of known files
if(projectPropertiesAddFileHash._indexin(_file_case(filename))) {
includeItem = 0;
}
// if still being included, check to see if it is one of the ignored extensions
if(includeItem == 1) {
_str ext = get_extension(filename, true);
if(projectPropertiesAddFileHash._indexin(_file_case(ext))) {
includeItem = 0;
}
}
return includeItem;
}
void _add.lbutton_up()
{
gFileListModified=1;
int form_wid=p_active_form;
_str config=ctlCurConfig.p_text;
int list_wid=_srcfile_list;
// init the callback so it clears its cache
projectPropertiesAddFilesCallback("");
typeless result=_OpenDialog("-modal "_stdform("_open_form"),
'Add Source Files',// title
_last_wildcards,// Initial wildcards
def_file_types','EXTRA_FILE_FILTERS,
// HS2-CHG: OFN_NOCHANGEDIR removed - maybe I want to come back near this (curr.) directory
// OFN_NOCHANGEDIR|OFN_FILEMUSTEXIST|OFN_ALLOWMULTISELECT|OFN_SET_LAST_WILDCARDS,
OFN_FILEMUSTEXIST|OFN_ALLOWMULTISELECT|OFN_SET_LAST_WILDCARDS,
"", // Default extension
""/*wildcards*/, // Initial filename
// HS2-ADD: change working dir if user explicitely changed project working dir #4
(use_projectdir_initially ? _prjworking_dir.p_text : ""), // Initial directory
"",
"",
projectPropertiesAddFilesCallback); // include item callback
// cleanup after the callback so it clears its cache
projectPropertiesAddFilesCallback("");
//chdir(olddir,1);
if (result=='') return;
int filelist_view_id=0;
int orig_view_id=_create_temp_view(filelist_view_id);
p_window_id=filelist_view_id;
_str file_spec_list = result;
while (file_spec_list != '') {
_str file_spec = parse_file(file_spec_list);
insert_file_list(file_spec' -v +p -d');
}
p_line=0;
_str path=strip_filename(gProjectName,'N');
int FileToNode:[];
int FilesNode=0;
_str AutoFolders='';
int ExtToNodeHashTab:[];
_str LastExt='';
int LastNode=0;
_InitAddFileToConfig(FileToNode,FilesNode,AutoFolders,ExtToNodeHashTab,LastExt,LastNode);
for (;;) {
if (down()) {
break;
}
_str filename='';
get_line(filename);
filename=substr(filename,2);
if (_DataSetIsFile(filename)) {
filename=upcase(filename);
}
AddFileToConfig(list_wid,relative(filename,path),config,FileToNode,FilesNode,AutoFolders,ExtToNodeHashTab,LastExt,LastNode);
}
_delete_temp_view(filelist_view_id);
activate_window(orig_view_id);
_srcfile_list._lbsort('-f');
_srcfile_list._remove_duplicates(_fpos_case);
_srcfile_list._lbtop();
}
static void updateControlsNofSelected()
{
_project_nofselected.p_caption=_srcfile_list.p_Nofselected' of '_srcfile_list.p_noflines' Files Selected';
if (!gLeaveFileTabEnabled) {
return;
}
// If there is nothing in _srcfile_list, disable Remove All button and
// if there is nothing selected in _srcfile_list, disable Remove button
ctlproperties.p_enabled=iswildcard(_srcfile_list._lbget_text());
if (_srcfile_list.p_noflines== 0) {
_remove_all.p_enabled= false;
_remove.p_enabled= false;
_invert.p_enabled= false;
} else {
_remove_all.p_enabled= true;
_invert.p_enabled= true;
if (_srcfile_list.p_Nofselected > 0) {
_remove.p_enabled= true;
} else {
_remove.p_enabled= false;
}
}
}
_srcfile_list.on_change()
{
updateControlsNofSelected();
/*
if (_openfn.p_enabled) {
//If this is disabled, the workspace is associated and the user cannot
//do this!!!
updateControlsAssociatedWithSrcFileList();
}
*/
}
_addtree.lbutton_up()
{
_str ConfigName=ctlCurConfig.p_text;
int list_wid=_srcfile_list;
_str wildcards='';
boolean attempt_retrieval=true;
int status=tag_read_db(_GetWorkspaceTagsFilename());
if (!status) {
_str extension='';
status=tag_find_extension(extension);
if (!status) {
wildcards=_ext2wildcards(extension);
_GetWildcardsForTagFile(false,wildcards);
attempt_retrieval=false;
//say('extension='extension);
//say('wildcards='wildcards);
}
tag_close_db(null,true);
}
if (wildcards=='') {
if (gIsJavaConfigType) {
wildcards=_ext2wildcards('java');
_GetWildcardsForTagFile(false,wildcards);
attempt_retrieval=false;
//say('wildcards='wildcards);
}
}
if (wildcards=='') {
wildcards=_default_c_wildcards();
}
int fid;
fid= p_active_form;
typeless result=show('-modal _addtree_form',
'Add Tree',
wildcards,
attempt_retrieval,
true
);
if (result== "") {
return("");
}
// Find all files in tree:
mou_hour_glass(1);
message('SlickEdit is finding all files in tree');
_str recursive=(_param2)?'+t':'-t';
_str OptimizeStats=(_param3)?'':'+o';
_str file_exclude = _param4;
int formwid=p_active_form;
int filelist_view_id=0;
int orig_view_id=_create_temp_view(filelist_view_id);
p_window_id=filelist_view_id;
_str orig_cwd=getcwd();
_str ProjectName=gProjectName;
_str all_files='';
int i;
for (i=0;i<_param1._length();++i) {
_str file=maybe_quote_filename(strip(absolute(_param1[i]),'B','"'));;
all_files=all_files' 'file;
}
if (file_exclude != '') {
_str exclude_list = '';
_str list = file_exclude;
while (list != '') {
parse list with file_exclude PATHSEP list;
if (file_exclude != '') {
if (exclude_list == '') {
exclude_list = ' -exclude ':+maybe_quote_filename(file_exclude);
} else {
strappend(exclude_list, ' 'maybe_quote_filename(file_exclude));
}
}
}
if (exclude_list != '') {
strappend(all_files, exclude_list);
}
}
// +W option supports multiple file specs but must specify switches
// before files when you use this option.
status=insert_file_list(recursive' 'OptimizeStats' +W +L -v +p -d 'all_files);
if (status==VSRC_OPERATION_CANCELLED) {
p_window_id=orig_view_id;
_delete_temp_view(filelist_view_id);
mou_hour_glass(0);
clear_message();
_message_box(get_message(VSRC_OPERATION_CANCELLED));
return('');
}
_param1._makeempty();
p_line=0;
int FileToNode:[];
int FilesNode=0;
_str AutoFolders='';
int ExtToNodeHashTab:[];
_str LastExt='';
int LastNode=0;
_InitAddFileToConfig(FileToNode,FilesNode,AutoFolders,ExtToNodeHashTab,LastExt,LastNode);
// Insert tree file list into project source file list:
top();up();
while (!down()) {
_str filename;
get_line(filename);
filename=strip(filename);
if (filename=='') break;
if (_DataSetIsFile(filename)) {
filename=upcase(filename);
}
//4:15pm 7/11/2000
//Changing for multiple configs...
//fid._srcfile_list._lbadd_item(filename);
//_srcfile_list._lbadd_item(relative(filename,strip_filename(gProjectName,'N')));
AddFileToConfig(list_wid,relative(filename,strip_filename(ProjectName,'N')),ConfigName,FileToNode,FilesNode,AutoFolders,ExtToNodeHashTab,LastExt,LastNode);
}
//Now sort the buffer...
p_window_id=orig_view_id;
_delete_temp_view(filelist_view_id);
// Sort and remove duplicate items in the project source file list:
fid._srcfile_list._lbsort('-f');
fid._srcfile_list._remove_duplicates(_fpos_case);
fid._srcfile_list._lbtop();
// Update the buttons associated with the lists:
fid._srcfile_list.call_event(CHANGE_SELECTED,_srcfile_list,ON_CHANGE,'');
// Remove all matching files in the directory file list:
gFileListModified=1;
// Indicate that the project source file list has been modified:
mou_hour_glass(0);
clear_message();
}
static void RemoveFileFromViews(_str RelativeFilename,_str ConfigName,int (&FileToNode):[])
{
int *pnode=FileToNode._indexin(_file_case(RelativeFilename));
if (!pnode) {
return;
}
int Node=*pnode;
gFileListModified=1;
//Simple case, we are in the "ALL CONFIGS" config, and we just remove the file
if (ConfigName==ALL_CONFIGS) {
_xmlcfg_delete(gProjectHandle,Node);
return;
}
_str configs=_xmlcfg_get_attribute(gProjectHandle,Node,'C');
// IF this file was in all configs
if (configs=='') {
int i;
for (i=0;i 1) fileMsg= "files";
_message_box("Project file list refreshed.\n\nRemoved "removed" "fileMsg".");
}
mou_hour_glass(0);
if (modified) {
gFileListModified=1;
}
}
_invert.lbutton_up()
{
_srcfile_list._lbinvert();
_srcfile_list.call_event(CHANGE_SELECTED,_srcfile_list,ON_CHANGE,'');
}
static int okFiles(boolean &doUpdateProjectToolbar)
{
doUpdateProjectToolbar=false;
int wid=p_active_form;
int cid;
cid= _find_control("_proj_prop_sstab");
//if (!sstIsControlExists("_srcfile_list") && !cid.sstIsPropInHash("_srcfile_list","p_exttext")) return( 0 );
// Update project:
int status= 0;
if (gFileListModified || !file_exists(_GetWorkspaceTagsFilename())) {
doUpdateProjectToolbar=1; // Could have modified wildcard properties
status=save_source_filenames(wid);
clear_message();
if (status) {
_message_box(nls("Error writing filenames"));
return(status);
}
}
return( status );
}
// Desc: Check to see if the text field has been modified.
// Retn: 1 for modified, 0 for not.
// 2 for not in original hash
static int isTextFieldModified(_str ctlName,typeless &ht)
{
_str value;
int cid;
cid= _find_control(ctlName);
value= "";
if (cid) value= cid.p_text;
if (!ht._indexin(ctlName)) return(2);
if (ht._indexin(ctlName) && value != ht:[ctlName]) return(1);
return(0);
}
// Desc: Check to see if the specified project tool in the new project
// tool table has been modified.
// Retn: 1 for table modified, 0 for not.
// 2 for tool not in original tool table
static int isProjectToolModified(ProjectToolStruct projectToolList[],
ProjectToolStruct oldprojectToolList[],
int toolIndex /* tool index in new table */)
{
// If the tool is not in the old tool table...
int otoolIndex;
_str name;
name= projectToolList[toolIndex].name;
if (!_isToolNameInProjectToolTable(oldprojectToolList,name,otoolIndex)) {
return(2);
}
if (otoolIndex!=toolIndex) {
return(1);
}
// Check individual fields...
ProjectToolStruct i1, i2;
i1= projectToolList[toolIndex];
i2= oldprojectToolList[otoolIndex];
if (i1.name != i2.name) {
//messageNwait("isProjectToolModified name");
return(1);
}
if (i1.nameKey != i2.nameKey) {
//messageNwait("isProjectToolModified nameKey");
return(1);
}
if (i1.cmd != i2.cmd) {
//messageNwait("isProjectToolModified cmd");
return(1);
}
if (i1.caption != i2.caption) {
//messageNwait("isProjectToolModified caption");
return(1);
}
if (i1.outputConcur != i2.outputConcur) {
//messageNwait("isProjectToolModified outputConcur");
return(1);
}
if (i1.captureOutput != i2.captureOutput) {
//messageNwait("isProjectToolModified captureOutput");
return(1);
}
if (i1.hideOptions != i2.hideOptions) {
//messageNwait("isProjectToolModified hideOptions");
return(1);
}
if (i1.clearProcessBuf != i2.clearProcessBuf) {
//messageNwait("isProjectToolModified clearProcessBuf");
return(1);
}
if (i1.saveOptions != i2.saveOptions) {
//messageNwait("isProjectToolModified saveOptions");
return(1);
}
if (i1.changeDir != i2.changeDir) {
//messageNwait("isProjectToolModified changeDir");
return(1);
}
if (i1.useVsBuild != i2.useVsBuild) {
//messageNwait("isProjectToolModified useVsBuild");
return(1);
}
if (i1.buildFirst != i2.buildFirst) {
//messageNwait("isProjectToolModified useVsBuild");
return(1);
}
if (i1.apptoolHashtab != i2.apptoolHashtab) {
return(1);
}
if (i1.appletClass != i2.appletClass) {
return(1);
}
#if __UNIX__
if (i1.runInXterm != i2.runInXterm) {
return(1);
}
#endif
if (i1.outputExtension != i2.outputExtension) {
return(1);
}
if (i1.noLinkObject != i2.noLinkObject) {
return(1);
}
if (i1.verbose != i2.verbose) {
return(1);
}
if (i1.beep != i2.beep) {
return(1);
}
if (i1.preMacro != i2.preMacro) {
return(1);
}
//if (i1.postMacro != i2.postMacro) {
// return(1);
//}
if (i1.otherOptions != i2.otherOptions) {
return(1);
}
//messageNwait("isProjectToolModified NO MODIFICATION");
return(0);
}
// Desc: Check to see if the project tool table has been modified.
// Retn: 1 for table modified, 0 for not.
static int isProjectToolListModified(ProjectToolStruct projectToolList[],ProjectToolStruct oldprojectToolList[])
{
// If the table are of different lengths, they are different:
if (projectToolList._length() != oldprojectToolList._length()) {
return(1);
}
// Check to see if the tool table has been changed:
int i;
for (i=0; i javaopts
// build -> javamake
// rebuild -> javarebuild
//
// if packtype equals 'gnuc'
// dialogs -> gnucopts
// build -> cppmake
// rebuild -> cpprebuild
//
// if packtype equals 'vcpp'
// dialogs -> vcppopts
// build -> ???
// rebuild -> ???
//
// default
// dialogs -> none
// build -> "%(VSLICKBIN1)vsbuild" make "%w" "%r"
// rebuild -> "%(VSLICKBIN1)vsbuild" rebuild "%w" "%r"
//
// automakefile
// dialogs -> none
// build -> (g)make -f "makefilename" CFG=%b
// rebuild -> (g)make -f "makefilename" rebuild CFG=%b
//
// custom
// dialogs -> none
// build -> none (user should fill these in)
// rebuild -> none (user should fill these in)
//
int BuildNode=_ProjectGet_TargetNode(gProjectHandle,'build',configName);
int RebuildNode=_ProjectGet_TargetNode(gProjectHandle,'rebuild',configName);
switch(BuildSystem) {
case "vsbuild":
if(isJavaProject) {
// build
_ProjectSet_TargetDialog(gProjectHandle,BuildNode,JAVA_OPTS_DLG_DEF);
//_ProjectSet_TargetCmdLine(gProjectHandle,BuildNode,"javamake",'');
_ProjectSet_TargetDialog(gProjectHandle,RebuildNode,JAVA_OPTS_DLG_DEF);
//_ProjectSet_TargetCmdLine(gProjectHandle,RebuildNode,"javarebuild",'');
} else if(isGNUCProject) {
_ProjectSet_TargetDialog(gProjectHandle,BuildNode,GNUC_OPTS_DLG_DEF);
//_ProjectSet_TargetCmdLine(gProjectHandle,BuildNode,"cppmake",'');
_ProjectSet_TargetDialog(gProjectHandle,RebuildNode,GNUC_OPTS_DLG_DEF);
//_ProjectSet_TargetCmdLine(gProjectHandle,RebuildNode,"cpprebuild",'');
} else if (isVCPPProject) {
_ProjectSet_TargetDialog(gProjectHandle,BuildNode,VCPP_OPTS_DLG_DEF);
_ProjectSet_TargetDialog(gProjectHandle,RebuildNode,VCPP_OPTS_DLG_DEF);
} else {
// build
_ProjectSet_TargetDialog(gProjectHandle,BuildNode,'');
// rebuild
_ProjectSet_TargetDialog(gProjectHandle,RebuildNode,'');
}
_ProjectSet_TargetCmdLine(gProjectHandle,BuildNode,"\"%(VSLICKBIN1)vsbuild\" build \"%w\" \"%r\"",'','');
_ProjectSet_TargetCmdLine(gProjectHandle,RebuildNode,"\"%(VSLICKBIN1)vsbuild\" rebuild \"%w\" \"%r\"",'','');
break;
case "automakefile":
// look for 'gmake' first. default to 'make' if not found
_str makeProgram = _findGNUMake();
// set the makefile name if it wasnt provided
if(BuildMakefile == "") {
BuildMakefile = "%rp%rn.mak";
}
// build
_ProjectSet_TargetDialog(gProjectHandle,BuildNode,'');
_ProjectSet_TargetCmdLine(gProjectHandle,BuildNode,makeProgram " -f \"" BuildMakefile "\" CFG=%b",'','');
// rebuild
_ProjectSet_TargetDialog(gProjectHandle,RebuildNode,'');
_ProjectSet_TargetCmdLine(gProjectHandle,RebuildNode,makeProgram " -f \"" BuildMakefile "\" rebuild CFG=%b",'','');
break;
default:
// build
_ProjectSet_TargetDialog(gProjectHandle,BuildNode,'');
_ProjectSet_TargetCmdLine(gProjectHandle,BuildNode,'','','');
// rebuild
_ProjectSet_TargetDialog(gProjectHandle,RebuildNode,'');
_ProjectSet_TargetCmdLine(gProjectHandle,RebuildNode,'','','');
break;
}
}
static ProjectDirStruct GetBlankDirInfo()
{
ProjectDirStruct rv;
rv.UserIncludeDirs='';
rv.SystemIncludeDirs='';
rv.ReferencesFile='';
//rv.WorkingDir='';
return(rv);
}
static ProjectCmdStruct GetBlankCmdInfo()
{
ProjectCmdStruct rv;
rv.PreBuildCmds = '';
rv.PostBuildCmds = '';
rv.StopOnPreBuildErrors = '0';
rv.StopOnPostBuildErrors = '0';
return(rv);
}
static _str getNewLineChars(_str text)
{
int p= pos("\n",text);
if (!p) return( "\n" ); // Can't find one so does not matter
if (p < 2) return( "\n" );
_str lc= substr(text,p-1,1);
if (lc== "\r") return( "\r\n" );
return( "\n" );
}
void _getMacroText(_str &text,int flags=EDC_OUTPUTINI)
{
typeless p;
if (flags & EDC_OUTPUTINI) {
save_pos(p);
top();
text=get_text(p_buf_size);
text=stranslate(text,'\\','\');
text=stranslate(text,'\n',p_newline);
restore_pos(p);
} else {
save_pos(p);
top();up();
text='';
for (;;) {
if (down()) {
break;
}
_str line;
get_line(line);
if (text!='') {
strappend(text,"\1");
}
strappend(text,line);
}
restore_pos(p);
}
}
_ok.lbutton_up()
{
mou_hour_glass(1);
doOK();
mou_hour_glass(0);
}
static void doOK()
{
_tbSetRefreshBy(VSTBREFRESHBY_PROJECT);
_str SectionsList[]=null;
boolean modified;
int fid=p_active_form;
fid.p_enabled=false;
boolean macrosChanged=false;
if (!gIsExtensionProject) {
okMacro(macrosChanged);
okDirectories();
// IMPORTANT: it is imperative that okBuildOptions() be called *before*
// okFiles(). the reason is an auto-generated makefile may
// be added/removed from the file list during okBuildOptions()
// and will need to be added/removed from the tag file
okBuildOptions();
if (!gIsProjectTemplate) {
// make sure dependencies are valid
if(okDependencies() < 0) {
// do not close the form if an invalid dependency is detected
fid.p_enabled=true;
return;
}
}
}
int status=0;
if (gIsExtensionProject || gIsProjectTemplate) { // extension project or project pack
modified=_xmlcfg_get_modify(gProjectHandle);
if (gdoSaveIfNecessary && _xmlcfg_get_modify(gProjectHandle)) {
if (gIsProjectTemplate) {
status=_ProjectTemplatesSave(gProjectHandle);
} else {
status=_ProjectSave(gProjectHandle,'',_config_path():+VSCFGFILE_USER_EXTPROJECTS);
}
if (status && p_active_form.p_visible) {
fid.p_enabled=true;
return;
}
}
if (gIsExtensionProject) {
readAndParseAllExtensionProjects();
}
// IF this is an extension specific project
//_project_refresh();
} else { // real project is opened
modified=_xmlcfg_get_modify(gProjectHandle);
boolean doUpdateProjectToolbar=false;
if (!gProjectFilesNotNeeded) {
status= fid.okFiles(doUpdateProjectToolbar);
if (status) {
fid.p_enabled=true;
return;
}
if (_IsWorkspaceAssociated(_workspace_filename)) {
int Node=_ProjectGet_FilesNode(gProjectHandle);
_xmlcfg_delete_children_with_name(gProjectHandle,Node,VPJTAG_F);
}
}
if (modified) {
if (gMakeCopyFirst) {
_xmlcfg_delete(gOrigProjectHandle,TREE_ROOT_INDEX,true);
_xmlcfg_copy(gOrigProjectHandle,TREE_ROOT_INDEX,gProjectHandle,TREE_ROOT_INDEX,VSXMLCFG_COPY_CHILDREN);
status=_ProjectSave(gOrigProjectHandle);
} else {
status=_ProjectSave(gProjectHandle);
}
//_message_box('save');
if (status && p_active_form.p_visible) {
fid.p_enabled=true;
return;
}
// IF we are modifying the active project
_ProjectCache_Update(gProjectName);
p_window_id._WorkspacePutProjectDate(gProjectName);
if (doUpdateProjectToolbar) {
toolbarUpdateFilterList(gProjectName);
}
// IF we are modifying the active project
if (file_eq(gProjectName,_project_name)) {
_DebugUpdateMenu();
}
p_window_id.call_list("_prjupdatedirs_");
// regenerate the makefile
p_window_id._maybeGenerateMakefile(gProjectName);
if (macrosChanged) {
_project_run_macro2();
}
}
if (gSetActiveConfigTo!='') {
project_config_set_active(gSetActiveConfigTo,gProjectName);
}
}
if (modified) {
p_window_id.call_list("_prjupdate_");
if (gUpdateTags) {
_TagCallList(TAGFILE_ADD_REMOVE_CALLBACK_PREFIX,'','');
_TagCallList(TAGFILE_REFRESH_CALLBACK_PREFIX);
}
}
//5:24pm 7/30/1999
//The window id changes to the toolbar in here somewhere.
fid.p_enabled=true;
p_window_id=fid;
int value= _proj_prop_sstab.p_ActiveTab;
_append_retrieve( _proj_prop_sstab, value );
fid._delete_window(modified);
#if 0
if (CurConfig!='') {
// This may display a rebuild dialog box for Java.
project_config_set_active(CurConfig);
}
#endif
}
void _proj_prop_sstab.on_change(int reason)
{
static _str previousConfig;
if (ctlCurConfig.p_enabled) {
// save the current configuration
previousConfig=ctlCurConfig.p_text;
}
if (previousConfig=='') {
return;
}
typeless status=0;
if (_proj_prop_sstab.p_ActiveTab == PROJPROPTAB_FILES) {
if (_IsWorkspaceAssociated(_workspace_filename)) {
if (reason==CHANGE_TABACTIVATED) {
// force configuration to "All Configurations"
ctlCurConfig.p_cb_list_box._lbtop();
status=ctlCurConfig.p_cb_list_box._lbsearch(ALL_CONFIGS);
if (status) {
ctlCurConfig.p_cb_list_box._lbbottom();
} else {
ctlCurConfig.p_cb_list_box._lbselect_line();
ctlCurConfig.call_event(CHANGE_SELECTED,ctlCurConfig,ON_CHANGE,'W');
}
ctlCurConfig.p_text=ctlCurConfig.p_cb_list_box._lbget_text();
// disable the config dropdown
ctlCurConfig.p_enabled=false;
} else if (reason==CHANGE_TABDEACTIVATED) {
// restore the configuration to whatever it was
ctlCurConfig.p_cb_list_box._lbtop();
status=ctlCurConfig.p_cb_list_box._lbsearch(previousConfig);
if (status) {
ctlCurConfig.p_cb_list_box._lbbottom();
} else {
ctlCurConfig.p_cb_list_box._lbselect_line();
ctlCurConfig.call_event(CHANGE_SELECTED,ctlCurConfig,ON_CHANGE,'W');
}
ctlCurConfig.p_text=ctlCurConfig.p_cb_list_box._lbget_text();
// re-enable the config dropdown
ctlCurConfig.p_enabled=true;
}
}
}
}
_prjcompile_concur.lbutton_up()
{
if (p_value) {
p_next.p_value=1;
}
}
_prjcompile_capture.lbutton_up()
{
if (!p_value) {
p_prev.p_value=0;
}
}
static void FillInSrcFileList(_str ConfigName)
{
if (gIsExtensionProject || gIsProjectTemplate) {
return;
}
if (!gOrigProjectFileList) {
GetProjectFiles(gProjectName, gOrigProjectFileList,'',null,'',true,true,false,gProjectHandle);
}
//_showbuf(gProjectInfo2:[ALL_CONFIGS].FilesViewId);
_lbclear();
_xmlcfg_find_simple_insert(gProjectHandle,VPJX_FILES"//"VPJTAG_F:+'[not(@C)]/@N');
//_showbuf(p_window_id);
if (ConfigName!=ALL_CONFIGS) {
_xmlcfg_find_simple_insert(gProjectHandle,VPJX_FILES"//"VPJTAG_F:+XPATH_CONTAINS('C',always_quote_filename(ConfigName),'i')'/@N');
}
top();search(FILESEP2,'@',FILESEP);
top();search('^','@R',' ');
_lbtop();
_lbsort('-f');
// Update all controls associated with the _srcfile_list
updateControlsNofSelected();
}
int _MaybeAddFilesToVC(_str NewFiles[])
{
int status=0;
int result=0;
if ( NewFiles._length() &&
( ( machine()=='NT386' && _isscc(_GetVCSystemName()) && _SCCProjectIsOpen() ) ||
_VCSCommandIsValid(VCS_CHECKIN_NEW)) ) {
result=_message_box(nls("Do you want to add the new files to version control?"),'',MB_YESNOCANCEL|MB_ICONQUESTION);
if (result==IDYES) {
if (def_vc_system=='CVS') {
status=_CVSAdd(NewFiles);
if (status) return(status);
result=_message_box(nls("Files added, commit these files now?"),'',MB_YESNO);
if (result==IDYES) {
_str comment_filename=mktemp(),tag='',filelist='';
int i,len=NewFiles._length();
for (i=0;i=NewFiles._length()) {
break;
}
result=show('-modal _vc_comment_form',NewFiles[i+1],1,1);
if (result=='') {
return(COMMAND_CANCELLED_RC);
}
comment=_param1;
prompt_for_each_comment=!_param2;
if (!prompt_for_each_comment) break;
}
if (i=NewFiles._length()) {
break;
}
result=show('-modal _vc_comment_form',NewFiles[i+1],1,1);
if (result=='') {
SkipNext=1;
continue;
}
comment=_param1;
prompt_for_each_comment=!_param2;
if (!prompt_for_each_comment) break;
}
int j;
for (j=i+1;j=0;Node=_xmlcfg_get_next_sibling(ProjectHandle,Node)) {
if (_xmlcfg_get_name(ProjectHandle,Node)!=VPJTAG_FOLDER) {
continue;
}
int index=TreeWid._TreeAddItem(TreeParentIndex,
_xmlcfg_get_attribute(ProjectHandle,Node,'Name'),
TREE_ADD_AS_CHILD,
_pic_tfldclos,
_pic_tfldopen,
0,0);
_str filters=_xmlcfg_get_attribute(ProjectHandle,Node,'Filters');
if (filters=='') {
ExtToNodeHashTab:['']=index;
continue;
}
for (;;) {
_str ext='';
parse filters with ext ';' filters;
parse ext with "*." ext;
if (ext=='' && filters=='') {
break;
}
if (ext!='') {
ExtToNodeHashTab:[lowcase(ext)]=index;
}
}
_CreateProjectFilterTree(TreeWid,index,ProjectHandle,Node,ExtToNodeHashTab,false);
}
if (SetOtherFilesNode && !ExtToNodeHashTab._indexin('')) {
ExtToNodeHashTab:['']=TreeParentIndex;
}
}
void _ProjectGet_ExtToNode(int handle,int (&ExtToNodeHashTab):[],_str SkipFolderName='')
{
XMLVARIATIONS xmlv;
_ProjectGet_XMLVariations(handle,xmlv);
ExtToNodeHashTab._makeempty();
int OtherFilesNode=-1;
typeless array;
_ProjectGet_Folders(handle,array);
boolean moreThanOne=false;
int i;
for (i=0;i=0) {
moreThanOne=true;
}
OtherFilesNode=array[i];
continue;
}
for (;;) {
_str ext='';
parse filters with ext ';' filters;
if (substr(ext,1,2)=='*.') {
parse ext with "*." ext;
}
if (ext=='' && filters=='') {
break;
}
if (ext!='') {
if (!ExtToNodeHashTab._indexin(lowcase(ext))) {
ExtToNodeHashTab:[lowcase(ext)]=array[i];
}
}
}
}
int FilesNode=_ProjectGet_FilesNode(handle,true);
if (OtherFilesNode<0 || moreThanOne) {
ExtToNodeHashTab:['']=FilesNode;
} else {
ExtToNodeHashTab:['']=OtherFilesNode;
}
}
int _TagUpdateFromViews(_str TagFilename,
int NewFilesViewId,
int OrigFilesViewId,
boolean InputIsAbsolute,
_str project_name=_project_name,
_str (&NewFilesList)[]=null,
_str (&DeletedFilesList)[]=null,
int database_flags=0
)
{
boolean tagFileModified=false;
int dbstatus=tag_open_db(TagFilename);
p_window_id=NewFilesViewId;
int num_files=p_Noflines;
static _str last_ext;
_str project_path=strip_filename(project_name,'N');
//_showbuf(NewFilesViewId);GetProjectFiles(project_name,CurProjectList_view_id,'','' /*Don't want associated project makefile */,"",true,false);_showbuf(CurProjectList_view_id);_delete_temp_view(CurProjectList_view_id);
if (dbstatus) {
int status= _OpenOrCreateTagFile(TagFilename,true,VS_DBTYPE_tags,database_flags);
#if 0
if (!status) {
activate_window(NewFilesViewId);
top();up();
for (;;) {
if (down()) {
break;
}
get_line(filename);
filename=strip(filename);
if (!InputIsAbsolute) {
filename=absolute(filename,project_path);
}
_str ext=_bufname2ext(filename);
if (last_ext==ext || _istagging_supported(ext) ||
index_callable(find_index('vs'ext'_load_tags',PROC_TYPE))) {
last_ext=ext;
message('Tagging 'p_line'/'num_files': 'filename);
#if DEBUG_TAGGING_MESSAGES
DebugTaggingMessage('Tagging 'p_line'/'num_files': 'filename);
#endif
RetagFile(filename);
}
}
}
#endif
}
{
//GetProjectFiles(project_name,CurProjectList_view_id,'','' /*Don't want associated project makefile */,"",true,false);
activate_window(NewFilesViewId);top();up();
int NofLines1=p_Noflines;
activate_window(OrigFilesViewId);top();up();
int NofLines2=p_Noflines;
if (NofLines1+NofLines2+10>_default_option(VSOPTION_WARNING_ARRAY_SIZE) ) {
_default_option(VSOPTION_WARNING_ARRAY_SIZE,NofLines1+NofLines2+10);
}
NewFilesList._makeempty();
DeletedFilesList._makeempty();
//_showbuf(OrigFilesViewId);
top();up();
boolean done1=false;
boolean done2=false;
activate_window(NewFilesViewId);
_str line1='';
if (down()) {
done1=1;
line1='';
} else {
get_line(line1);
line1=strip(line1);
}
activate_window(OrigFilesViewId);
_str line2='';
if (down()) {
done2=1;
line2='';
} else {
get_line(line2);
}
line2=strip(line2);
int buildform_wid=0;
boolean allowCancel=false;
if (allowCancel) {
buildform_wid=show_cancel_form('Building Tag File...',null,true,true);
} else {
buildform_wid=show_cancel_form('Building Tag File...','',false,true);
}
int max_label2_width=cancel_form_max_label2_width(buildform_wid);
for (;;) {
if (cancel_form_cancelled()) {
break;
}
if (done1 && done2) {
break;
}
if (!done1 && !done2 && file_eq(line1,line2)) {
activate_window(NewFilesViewId);
if (down()) {
done1=1;
line1='';
} else {
get_line(line1);
}
line1=strip(line1);
activate_window(OrigFilesViewId);
if (down()) {
done2=1;
line2='';
} else {
get_line(line2);
}
line2=strip(line2);
continue;
}
// If we are add a file to the project
if (!done1 && (done2 || _file_case(line1)<_file_case(line2))) {
for (;;) {
if (cancel_form_cancelled()) {
break;
}
// call tag progress callback
int cancelPressed = tagProgressCallback(p_line * 100 intdiv num_files, true);
if(cancelPressed) break;
activate_window(NewFilesViewId);
NewFilesList[NewFilesList._length()]=line1;
_str filename='';
if (!InputIsAbsolute) {
filename=absolute(line1,project_path);
}else{
filename=line1;
}
//say('***add 'absolute(line1,project_path));
_str ext=_bufname2ext(filename);
if (last_ext==ext || _istagging_supported(ext) ||
index_callable(find_index('vs'ext'_load_tags',PROC_TYPE))) {
if (cancel_form_progress(buildform_wid,p_line-1,num_files)) {
_str sfilename=buildform_wid._ShrinkFilename(filename,max_label2_width);
cancel_form_set_labels(buildform_wid,'Tagging 'p_line'/'num_files':',sfilename);
}
//message('Tagging 'p_line'/'num_files': 'filename);
#if DEBUG_TAGGING_MESSAGES
DebugTaggingMessage('Tagging 'p_line'/'num_files': 'filename);
#endif
RetagFile(filename);
}
activate_window(NewFilesViewId);
if (down()) {
done1=1;
line1='';
break;
} else {
get_line(line1);
}
line1=strip(line1);
if (!done2 && _file_case(line1)>=_file_case(line2)) {
break;
}
}
continue;
}
// We are deleting files from the project
for (;;) {
if (cancel_form_cancelled()) {
break;
}
//say('***remove 'absolute(line2,project_path));
DeletedFilesList[DeletedFilesList._length()]=line2;
_str filename='';
if (!InputIsAbsolute) {
filename=absolute(line2,project_path);
}else{
filename=line2;
}
_str ext=_bufname2ext(filename);
if (last_ext==ext || _istagging_supported(ext) ||
index_callable(find_index('vs'ext'_load_tags',PROC_TYPE))) {
_str sfilename=buildform_wid._ShrinkFilename(filename,max_label2_width);
cancel_form_set_labels(buildform_wid,'Removing:',sfilename);
//message('Removing 'filename' from 'TagFilename);
#if DEBUG_TAGGING_MESSAGES
DebugTaggingMessage('Removing 'filename' from 'TagFilename);
#endif
tag_remove_from_file(filename, 1);
}
activate_window(OrigFilesViewId);
if (down()) {
done2=1;
line2='';
break;
} else {
get_line(line2);
}
line2=strip(line2);
if (!done1 && _file_case(line1)<=_file_case(line2)) {
break;
}
}
}
if (buildform_wid) {
close_cancel_form(buildform_wid);
}
tag_close_db(TagFilename,1);
//_showbuf(addfiles_view_id);_delete_temp_view(addfiles_view_id);
}
_TagCallList(TAGFILE_MODIFIED_CALLBACK_PREFIX,TagFilename);
_TagCallList(TAGFILE_REFRESH_CALLBACK_PREFIX);
clear_message();
return(0);
}
//12:08:14 PM 9/13/2000
//Wrote this because I kind of wanted to have these messages in there for quite
//a while so I could see what was going on, but I didn't want to have calls
//to say(made it harder to take out the "short term" calls to say).
static void DebugTaggingMessage(_str Msg)
{
say(Msg);
}
static int save_source_filenames(int form_wid)
{
if (gIsExtensionProject || gIsProjectTemplate) return( 0 );
if (_IsEclipseWorkspaceFilename(_workspace_filename)) {
return(0);
}
if (_IsWorkspaceAssociated(_workspace_filename)) {
int temp_view_id=0;
int orig_view_id=_create_temp_view(temp_view_id);
_xmlcfg_find_simple_insert(gProjectHandle,VPJX_FILES"//"VPJTAG_F'/@N');
top();search(FILESEP2,'@',FILESEP);
int status=SaveAssociatedProjectFiles(temp_view_id,gProjectName);
_delete_temp_view(temp_view_id);
activate_window(orig_view_id);
return(status);
}
int orig_view_id=p_window_id;
activate_window(gOrigProjectFileList);
sort_buffer('-fc');
_remove_duplicates(_fpos_case);
int new_all_files_view_id=0;
GetProjectFiles(gProjectName, new_all_files_view_id,'',null,'',true,true,false,gProjectHandle);
//_showbuf(new_all_files_view_id);
activate_window(new_all_files_view_id);
sort_buffer('-fc');
_remove_duplicates(_fpos_case);
cancel_form_set_parent(form_wid);
_str NewFilesList[];
_str DeletedFilesList[];
int database_flags=(def_references_options & VSREF_NO_WORKSPACE_REFS)? 0:VS_DBFLAG_occurrences;
_TagUpdateFromViews(project_tags_filename(),new_all_files_view_id,
gOrigProjectFileList,false,gProjectName,
NewFilesList,DeletedFilesList,database_flags);
cancel_form_set_parent(0);
_delete_temp_view(new_all_files_view_id);
//_delete_temp_view(old_all_files_view_id);
/*
Need to do this after tagging so we can query the package names from the
tag data base.
*/
_str AutoFolders=_ProjectGet_AutoFolders(gProjectHandle);
if (strieq(AutoFolders,VPJ_AUTOFOLDERS_CUSTOMVIEW)) {
int ExtToNodeHashTab:[];
_ProjectGet_ExtToNode(gProjectHandle,ExtToNodeHashTab);
_ProjectSortFolderNodesInHashTable(gProjectHandle,ExtToNodeHashTab);
} else {
_ProjectAutoFolders(gProjectHandle);
}
_AddAndRemoveFilesFromVC(NewFilesList,DeletedFilesList);
p_window_id=form_wid;
return(0);
}
// Desc: Check to specified tool command for modifications.
// Retn: 1 for modified, 0 for nothing modified.
static int isProjectShellCommandModified(_str ctlName, typeless & ht)
{
int wid;
/*
wid= sstIsControlExists(ctlName);
if (!wid) {
_str widptext;
int concur, capture;
widptext= _proj_prop_sstab.sstGetProp2(ctlName,"p_text");
if (!ht._indexin(ctlName)) {
old_text='';
} else {
old_text=ht:[ctlName];
}
if (widptext != old_text) return(1);
concur= _proj_prop_sstab.sstGetProp2(ctlName:+"_concur","p_value");
if (ht._indexin(ctlName:+"_concur") && concur != ht:[ctlName:+"_concur"]) return(1);
capture= _proj_prop_sstab.sstGetProp2(ctlName:+"_capture","p_value");
if (ht._indexin(ctlName:+"_capture") && capture != ht:[ctlName:+"_capture"]) return(1);
return(0);
}
*/
wid= _find_control(ctlName);
if (!wid) {
return(0);
}
int concurwid, capturewid;
concurwid= wid.p_next.p_next;
capturewid= concurwid.p_next;
_str old_text='';
if (!ht._indexin(ctlName)) {
old_text='';
} else {
old_text=ht:[ctlName];
}
if (wid.p_text != old_text) return(1);
if (ht._indexin(ctlName:+"_concur") && concurwid.p_value != ht:[ctlName:+"_concur"]) return(1);
if (ht._indexin(ctlName:+"_capture") && capturewid.p_value != ht:[ctlName:+"_capture"]) return(1);
return(0);
}
_browsedir.lbutton_up()
{
int wid=p_window_id;
// TODO: save and restore def_cd variable here
typeless result=show('-modal '_stdform('_cd_form'),'Choose Directory',1,1,1);
result=strip(result,'B','"');
if ( result=='' ) {
return('');
}
p_window_id=wid.p_prev;
if (p_object==OI_TREE_VIEW) {
_TreeBottom();
int lastIndex=_TreeCurIndex(); // get the index of the _default_option(VSOPTION_WARNING_ARRAY_SIZE)) {
_default_option(VSOPTION_WARNING_ARRAY_SIZE,p_Noflines+10);
}
_str line;
top();up();
int i;
i= 0;
while (!down()) {
get_line(line);
fileList[i]=line;
++i;
}
_delete_temp_view(ini_view_id);
activate_window(view_id);
return(0);
}
static int isPatternAllFilesRE(_str pattern)
{
#if __UNIX__
return(pos(';'ALLFILES_RE';',';'pattern';',1,_fpos_case));
/*return(pos(';*.*;',';'pattern';',1,_fpos_case) ||
pos(';*;',';'pattern';',1,_fpos_case));*/
#else
return(pos(';'ALLFILES_RE';',';'pattern';',1,_fpos_case));
#endif
}
// Desc: Check to see if the specified file has one of the extensions
// listed in semicolon-separated pattern.
static int isFileMatchedExtension(_str name, _str pattern)
{
_str ext= get_extension(name);
if (ext=='') {
return(isPatternAllFilesRE(pattern));
}
int status=pos(';*.'ext';',';'pattern';',1,_fpos_case);
if (status) {
return(status);
}
return(isPatternAllFilesRE(pattern));
}
static boolean IsReadOnly(_str filename)
{
#if __UNIX__
_str attrs=file_list_field(filename,DIR_ATTR_COL,DIR_ATTR_WIDTH);
if (attrs=='') return(0);
int w=pos('w',attrs,'','i');
return(w != 0);
#else
_str attrs=file_list_field(filename,DIR_ATTR_COL,DIR_ATTR_WIDTH);
if (attrs=='') return(0);
int ro=pos('r',attrs,1,'i');
return(ro != 0);
#endif
}
/*
int _pic_vc_co_user_r; // File under version control checked out by user, read-only
int _pic_vc_co_other_m_r; // File under version control checked out by other user multiple, read-only
int _pic_vc_co_other_x_r; // File under version control checked out by other user exclusive, read-only
int _pic_vc_available_r; // File under version control not checked read-only
int _pic_doc_r; // File NOT under version control read-only
int _pic_vc_co_user_w; // File under version control checked out by user, writable
int _pic_vc_co_other_m_w; // File under version control checked out by other user multiple, writable
int _pic_vc_co_other_x_w; // File under version control checked out by other user exclusive, writable
int _pic_vc_available_w; // File under version control not checked writable
int _pic_doc_w; // File NOT under version control writable
*/
void _SetProjTreeColWidth()
{
// Initialize tree column width to at least fit the project name.
// This width may be changed by _InsertProjectFileList().
int longestWW=0;
int index=_TreeGetFirstChildIndex(TREE_ROOT_INDEX);
for (;;) {
if (index<0) {
break;
}
_str nameOnly='';
_str path='';
parse _TreeGetCaption(index) with nameOnly "\t" path;
int cur=/*_proj_tooltab_tree.*/_text_width(nameOnly);
if (cur>longestWW+400) {
longestWW=cur;
}
index=_TreeGetNextSiblingIndex(index);
}
//curwidth=_col_width(0);
/*_proj_tooltab_tree.*/_col_width(0, longestWW + PROJECTTREEADJUSTCOLUMNWIDTH);
}
static void _projecttbSortFolder(int Node)
{
// Sort this node but keep sort order of folders
//int FolderOrder:[];
_str FolderNames[];
int i,child=_TreeGetFirstChildIndex(Node);
for (i=0;child>=0;child=_TreeGetNextSiblingIndex(child),++i) {
if (_projecttbIsFolderNode(child)) {
//FolderOrder:[_TreeGetCaption(child)]=i;
FolderNames[i]=_TreeGetCaption(child);
}
}
_TreeSortCaption(Node,'2P');
int CurFolderOrder:[];
child=_TreeGetFirstChildIndex(Node);
for (i=0;child>=0;child=_TreeGetNextSiblingIndex(child),++i) {
if (!_projecttbIsFolderNode(child)) {
break;
}
CurFolderOrder:[_TreeGetCaption(child)]=i;
}
// Now fix the order of the folders
child=_TreeGetFirstChildIndex(Node);
for (i=0;i0) {
while(count--) _TreeMoveUp(index);
}
}
}
//4:28pm 5/3/1999
//Dan made this global to call it from wkspace.e
int toolbarBuildFilterList(_str projectName,int ProjectIndex=-1)
{
if (projectName== "") return(0);
/*
If there are more than 1000 files in the project,
don't fill in the extensions
return(0);
*/
// Show project name in root node:
_nocheck _control _proj_tooltab_tree;
_proj_tooltab_tree._TreeSetInfo(TREE_ROOT_INDEX,0,_pic_workspace,_pic_workspace);
_SetProjTreeColWidth();
_str name='';
int status=0;
int doneCount = 0;
int i = 0;
typeless t;
_str FolderName='';
//This code was dead.
_proj_tooltab_tree._TreeSetInfo(TREE_ROOT_INDEX, 1);
int BitmapIndexList[];
BitmapIndexList[0]=_pic_doc_w;
BitmapIndexList[1]=_pic_doc_r;
BitmapIndexList[2]=_pic_vc_co_user_w;
BitmapIndexList[3]=_pic_vc_co_user_r;
BitmapIndexList[4]=_pic_vc_co_other_x_w;
BitmapIndexList[5]=_pic_vc_co_other_x_r;
BitmapIndexList[6]=_pic_vc_co_other_m_w;
BitmapIndexList[7]=_pic_vc_co_other_m_r;
BitmapIndexList[8]=_pic_vc_available_w;
BitmapIndexList[9]=_pic_vc_available_r;
BitmapIndexList[10]=_pic_doc_ant;
mou_hour_glass(1);
_str DisplayName=GetProjectDisplayName(projectName);
_str capname=strip_filename(DisplayName,'p')"\t"_RelativeToWorkspace(DisplayName);
if (ProjectIndex<0) {
ProjectIndex=_TreeSearch(TREE_ROOT_INDEX,capname,_fpos_case);
if (ProjectIndex<0) {
return(0);
}
}
int orig_wid=p_window_id;
p_window_id=_proj_tooltab_tree;
int tree_wid=_proj_tooltab_tree;
_TreeDelete(ProjectIndex,'C');
projectName=VSEProjectFilename(projectName);
//1:45pm 3/1/2000
//Using a 0 for this parameter defeats querying an SCC version control system
//for the icon to use for each file. This will increase performance when using
//slower version control systems. There may be an option for this in the future.
#if 1
int check_SCC_Status=_isscc();
#else
int check_SCC_Status=0;
#endif
if(_IsWorkspaceAssociated(_workspace_filename)) {
_InsertAssociatedProjectFileList(projectName,
BitmapIndexList,
def_optimize_sccprjfiles,
_pic_tfldclos,
_pic_tfldopen,
check_SCC_Status,
ProjectIndex);
} else {
/*
- Don't insert Refilter=1 wildcard files
- Expand wildcards other wildcards
*/
int project_handle=_ProjectHandle(projectName);
int ExtToNodeHashTab:[];
boolean BackedUpXMLFilesSection=false;
int backup_project_handle=-1;
typeless array;
_xmlcfg_find_simple_array(_ProjectHandle(projectName),
VPJX_FILES"//"VPJTAG_F:+
//XPATH_CONTAINS('N','['_escape_re_chars(WILDCARD_CHARS)']','r'),
XPATH_CONTAINS('N','['_escape_re_chars(WILDCARD_CHARS)']','r'),
array,TREE_ROOT_INDEX);
boolean projectHasWildcards=array._length()!=0;
_str FoldersToSort:[];
boolean done=false;
_str AutoFolders=_ProjectGet_AutoFolders(project_handle);
boolean CustomView=strieq(AutoFolders,VPJ_AUTOFOLDERS_CUSTOMVIEW);
if (array._length()) {
if (!CustomView) {
if (!BackedUpXMLFilesSection) {
BackedUpXMLFilesSection=true;
backup_project_handle=_xmlcfg_create('',VSENCODING_UTF8);
_xmlcfg_copy(backup_project_handle,TREE_ROOT_INDEX,project_handle,_ProjectGet_FilesNode(project_handle),VSXMLCFG_COPY_CHILDREN);
}
}
/*_InsertAssociatedProjectFileList(projectName,
BitmapIndexList,
def_optimize_sccprjfiles,
_pic_tfldclos,
_pic_tfldopen,
check_SCC_Status,
ProjectIndex);
*/
if (!done) {
_str pathList[]=null;
if (_IsEclipseWorkspaceFilename(_workspace_filename)) {
status=_GetEclipsePathList(strip_filename(projectName,'N'),pathList);
}else{
pathList[0]=strip_filename(projectName,'N');
}
int folderNodeHash:[];
int PrevParentNode= -1;
for (i=0;i_default_option(VSOPTION_WARNING_ARRAY_SIZE)) {
_default_option(VSOPTION_WARNING_ARRAY_SIZE,p_Noflines+10);
}
_str line;
top();up();
i= 0;
while (!down()) {
get_line(line);
fileList[i]=line;
++i;
}
activate_window(orig_view_id);
_InsertProjectFileList(fileList,
ExtToNodeHashTab,//assocTypeList,
//patternList,
BitmapIndexList,
MAXINT,
def_optimize_sccprjfiles,
check_SCC_Status);
boolean NodeDoneHashTab:[];
// Now sort all the files
for (t._makeempty();;) {
int Node=ExtToNodeHashTab._nextel(t);
if (t._isempty()) {
break;
}
if (NodeDoneHashTab._indexin(Node)) {
continue;
}
NodeDoneHashTab:[Node]=true;
//_projectbSortFolder(Node);
tree_wid._TreeSortCaption(Node,'2=');
}
} else {
for (t._makeempty();;) {
FolderName=FoldersToSort._nextel(t);
if (t._isempty()) {
break;
}
int index=_TreeSearch(ProjectIndex,FolderName,'T');
if (FolderName=='' || index<0) {
index=ProjectIndex;
}
tree_wid._TreeSortCaption(index,'2=');
//_projecttbSortFolder(index);
}
}
}
// IF there are wildcards in this project
if (projectHasWildcards) {
// Remove the duplicates
tree_wid._TreeRemoveDuplicatesSpecial(ProjectIndex);
}
}
}
tree_wid._toolbarUpdateDependencies2(ProjectIndex);
p_window_id=orig_wid;
mou_hour_glass(0);
return(status);
}
static void _TreeRemoveDuplicatesSpecial(int index)
{
index=_TreeGetFirstChildIndex(index);
if (!index) return;
for (;;) {
if (index<0) {
return;
}
if(_projecttbIsFolderNode(index)) {
_TreeRemoveDuplicatesSpecial(index);
} else if(_projecttbIsProjectFileNode(index)) {
break;
}
index=_TreeGetNextSiblingIndex(index);
}
_str projectPath=strip_filename(_projecttbTreeGetCurProjectName(index,false),'N');
_str caption,fullPath;
_str fullPath2='';
caption= _TreeGetCaption(index);
_str name='';
parse caption with name "\t" fullPath;
fullPath=absolute(fullPath,projectPath);
index=_TreeGetNextSiblingIndex(index);
for (;;) {
if (index<0) {
break;
}
caption= _TreeGetCaption(index);
parse caption with name "\t" fullPath2;
fullPath2=absolute(fullPath2,projectPath);
if (file_eq(fullPath,fullPath2)) {
_TreeDelete(_TreeGetPrevSiblingIndex(index));
}
fullPath=fullPath2;
index=_TreeGetNextSiblingIndex(index);
}
}
static void DeleteDepenciesFromTree(int index)
{
index=_TreeGetFirstChildIndex(index);
int DeleteIndexes[];
int state=0;
int bm1=0, bm2=0;
for (;;) {
if (index<0) {
break;
}
_TreeGetInfo(index,state,bm1,bm2);
if (bm1==_pic_project) {
DeleteIndexes[DeleteIndexes._length()]=index;
}
index=_TreeGetNextSiblingIndex(index);
}
int i;
for (i=0;i-1) {
LastIndex=BottomIndex;
BottomIndex=_TreeGetNextSiblingIndex(BottomIndex);
}
if (LastIndex>-1) {
int NewIndex=_TreeAddItem(LastIndex,NewCap,0,BmIndex1,BmIndex2,State);
}
return(-1);
}
static _str _RemoveDuplicatesFromList(_str list)
{
_str array[];
for (;;) {
_str cur=parse_file(list,false);
if (cur=='') {
break;
}
array[array._length()]=cur;
}
array._sort('2');
_aremove_duplicates(array,upcase(_fpos_case)=='i');
list='';
int i;
for (i=0;i=0 &&
ShowChildren==1 // Only update the projects that are expanded.
) {
formid._proj_tooltab_tree.DeleteDepenciesFromTree(index);
_str list=_RemoveDuplicatesFromList(Dependencies:[i]);
for (;;) {
_str cur=parse_file(list);
if (cur=='') {
break;
}
HandledProjects:[_file_case(Cap)]=Cap;
_str NewCap=strip_filename(strip(cur,'B','"'),'P')"\t"strip(cur,'B','"');
formid._proj_tooltab_tree.InsertAtBottom(index,NewCap,_pic_project,_pic_project);
}
}
}
for (i._makeempty();;) {
HandledProjects._nextel(i);
if (i._isempty()) break;
}
// Delete old dependencies
int index=_TreeGetFirstChildIndex(TREE_ROOT_INDEX);
for (;;) {
if (index<0) break;
_str cap=_TreeGetCaption(index);
if (!HandledProjects._indexin(_file_case(cap))) {
DeleteChildWithBMIndex(index,_pic_project);
}
index=_TreeGetNextSiblingIndex(index);
}
p_window_id=oriWindowId;
}
static void DeleteChildWithBMIndex(int TreeIndex,int BMIndex)
{
int cindex=_TreeGetFirstChildIndex(TreeIndex);
int state=0;
int bm1=0, bm2=0;
for (;;) {
if (cindex<0) return;
_TreeGetInfo(cindex,state,bm1,bm2);
int nextindex=_TreeGetNextSiblingIndex(cindex);
if (bm1==BMIndex || bm2==BMIndex) {
_TreeDelete(cindex);
}
cindex=nextindex;
}
}
/**
* 4:31pm 8/22/1997
* This was static, but Dan made it global so that the project toolbar
* could be updated if someone added/removed a project file from the
* make tags dialog
*
* @param projectName Absolute project name.
* @param projectIndex Idono
* @return int
*/
int toolbarUpdateFilterList(_str projectName,int projectIndex=-1,int formid=-1)
{
int oriWindowId= p_window_id;
//int formid;
if (formid<0) {
formid= _find_object("_tbprojects_form","N");
if (!formid) {
p_window_id= oriWindowId;
return(0);
}
}
_nocheck _control _proj_tooltab_tree;
p_window_id= formid._proj_tooltab_tree.p_window_id;
// Delete all level 1 nodes in tree view and remember the expansion list:
int expansionModeList[];
_str expansionNameList[];
int childL1;
childL1= formid._proj_tooltab_tree._TreeGetFirstChildIndex(TREE_ROOT_INDEX);
if (childL1<0) {
toolbarUpdateWorkspaceList();
p_window_id= oriWindowId;
return(0);
}
typeless p;
_TreeSavePos(p);
_str States[];
_GetProjTreeStates(States);
if (projectIndex<0) {
_str DisplayName=GetProjectDisplayName(projectName);
projectIndex=_TreeSearch(TREE_ROOT_INDEX,strip_filename(DisplayName,'P')"\t"DisplayName,_fpos_case);
if (projectIndex>=0) {
formid._proj_tooltab_tree._TreeDelete(projectIndex,'C');
}
}
// If no current project
if (projectName== "") {
_str text;
text= " No Project ";
int longestWW;
longestWW= formid._proj_tooltab_tree._text_width(text);
//formid._proj_tooltab_tree._TreeSetCaption(TREE_ROOT_INDEX, text);
formid._proj_tooltab_tree._col_width(0, longestWW + PROJECTTREEADJUSTCOLUMNWIDTH);
p_window_id= oriWindowId;
return(0);
}
// Build new tree:
toolbarBuildFilterList(projectName,projectIndex);
// Reset expansion state:
_RestoreProjTreeStates(States);
_TreeRestorePos(p);
p_window_id= oriWindowId;
//toolbarUpdateDependencies();
return(0);
}
//Start DANS STUFF
void _actapp_makefile()
{
if (!def_actapp) {
return;
}
_MaybeRetagWorkspace(arg(1));
}
int _OnUpdate_project_add_file(CMDUI &cmdui,int target_wid, _str command)
{
_str cmdname='';
_str filename='';
parse command with cmdname filename;
if (_workspace_filename=='' || _project_name=='') {
return(MF_GRAYED);
}
if (filename=="") {
if ( !target_wid || !target_wid._isEditorCtl()) {
return(MF_GRAYED);
}
filename=target_wid.p_buf_name;
}
// For now, its too slow to check whether the file is
// already in the project. If we every cache the project
// files or keep the project file loaded, we can do better.
#if 0
// Code below only works for taggable project files
filename=absolute(strip(filename,'B','"'));
tag_files=project_tags_filename();
for (;;) {
parse tag_files with tag_filename tag_files;
if (tag_filename=="") {
break;
}
int status= tag_read_db(tag_filename);
if (!status) {
// get the files from the database
int status=tag_get_date(filename,tagged_date);
if (!status) {
return(MF_GRAYED);
}
}
}
#endif
return(MF_ENABLED);
}
boolean _FileExistsInCurrentProject(_str filename,_str ProjectName=_project_name)
{
int orig_view_id=p_window_id;
int FileViewId=0;
GetProjectFiles(ProjectName,FileViewId);
p_window_id=FileViewId;
top();up();
int status=search('^'_escape_re_chars(filename)'$','@r'_fpos_case);
p_window_id=orig_view_id;
_delete_temp_view(FileViewId);
return(!status);
}
boolean _FileExistsInCurrentWorkspace(_str filename,_str WorkspaceName=_workspace_filename)
{
_str project_names[];
_GetWorkspaceFiles(WorkspaceName,project_names);
len := project_names._length();
for (i:=0;i 1) {
// prompt the user for the file
return show("-modal _sellist_form", "Select filename", SL_SELECTCLINE, foundFileList);
// if only found one
} else if(foundFileList._length() == 1) {
return foundFileList[0];
}
// nothing found
return "";
}
/**
* First searches the current project for filename,
* then the current workspace. If that fails, it reduces
* filename to it's basename and searches again.
* If that fails, it searches include paths as defined by
* the current project.
*
* @param filename path of file to search for
* @param searchIncludes search the project include paths
* @param strict search only for exact matches,
* do not strip path from filename
*
* @return '' if not found, otherwise, the absolute path
* to filename.
*/
_str _ProjectWorkspaceFindFile(_str filename,
boolean searchIncludes=true,
boolean strict=false)
{
// if not found, search for file in the current project
_str found_filename=_ProjectFindFile(filename);
if (found_filename!='') {
return found_filename;
}
// if not found, search for file in the current workspace
found_filename=_WorkspaceFindFile(filename);
if (found_filename!='') {
return found_filename;
}
// if not found, search for file (by name only) in the current project
_str filename_only = strip_filename(filename,'P');
if (!strict) {
found_filename=_ProjectFindFile(filename_only, _project_name, false);
if (found_filename!='') {
return found_filename;
}
// if not found, search for file (by name only) in the current workspace
found_filename=_WorkspaceFindFile(filename_only);
if (found_filename!='') {
return found_filename;
}
}
// if not found, search include paths
_str info=_ProjectGet_IncludesList(_ProjectHandle(),_project_get_section(gActiveConfigName));
info=_absolute_includedirs(info, _project_get_filename());
found_filename=include_search(filename,info);
if(found_filename!='') {
return found_filename;
}
// no match
return '';
}
/**
* Search for a file in any project in the specified workspace
*
* @param filename File to search for
* @param workspaceName
* Workspace path
* @param isAbsolute T if the specified filename is an absolute path
* @param quiet T if we should just take the first match
*
* @return Project containing the file if found
*/
_str _WorkspaceFindProjectWithFile(_str filename, _str workspaceName = _workspace_filename,
boolean isAbsolute = false, boolean quiet = false)
{
_str projectList[] = null;
_GetWorkspaceFiles(workspaceName, projectList);
int i = 0;
_str foundFileHash:[] = null;
for(i = 0; i < projectList._length(); i++) {
_str projectName = _AbsoluteToWorkspace(projectList[i], workspaceName);
// if the filename was absolute, make it relative to the project first
_str relativeFilename = filename;
if(isAbsolute) {
relativeFilename = _RelativeToProject(relativeFilename, projectName);
}
// search this project for the file
if(_ProjectFindFile(relativeFilename, projectName) != "") {
// if quiet option, just return the first match
if(quiet && projectName==_project_name) {
return projectName;
}
foundFileHash:[projectName] = projectName;
}
}
// build array of files to send to _sellist_form
_str foundFileList[] = null;
typeless j;
for(j._makeempty();;) {
foundFileHash._nextel(j);
if(j._isempty()) break;
foundFileList[foundFileList._length()] = j;
}
// sort the array
foundFileList._sort("F");
// if found more than one, prompt the user for which one
if(foundFileList._length() >= 1) {
if (quiet || foundFileList._length() == 1) {
return foundFileList[0];
}
// prompt the user for the file
return show("-modal _sellist_form", "Select project", SL_SELECTCLINE, foundFileList);
}
// nothing found
return "";
}
/**
* Returns list built from the tree delimited by the specified
* delimiter.
*
* IMPORTANT: p_window_id *must* be a tree control
*
* @param delimiter
*
* @return
*/
_str _TreeGetDelimitedItemList(_str delimiter)
{
_str list = '';
if(p_window_id._TreeGetNumChildren(TREE_ROOT_INDEX) > 0) {
int index = p_window_id._TreeGetFirstChildIndex(TREE_ROOT_INDEX);
for(; index >= 0; ) {
// get the caption and skip the node reserved for new entry
//if(!strieq(caption, BLANK_TREE_NODE_MSG)) {
if (!isItemBold(index)) {
_str caption = p_window_id._TreeGetCaption(index);
if(list != '') {
list = list :+ delimiter :+ caption;
} else {
list = caption;
}
}
// move to next node
index = p_window_id._TreeGetNextSiblingIndex(index);
}
}
return list;
}
/*void _TreeAddNodeList(int handle,int (&NodeArray)[], _str AttrName, boolean allowDuplicates = false)
{
// remove previous list items
p_window_id._TreeDelete(TREE_ROOT_INDEX, 'C');
for(i=0;i= 0) {
continue;
}
p_window_id._TreeAddListItem(value);
}
}
// add the node for new data
int newIndex = p_window_id._TreeAddListItem(BLANK_TREE_NODE_MSG);
p_window_id._TreeSetInfo(newIndex, 0, -1, -1, TREENODE_BOLD);
} */
/**
* Builds the tree from the list delimited by the specified
* delimiter.
*
* IMPORTANT: p_window_id *must* be a tree control
*
* @param list List of items to be entered into the tree
* @param delimiter Delimiter separating each item in the list
* @param allowDuplicates
* Allow duplicate nodes in the tree
*/
void _TreeSetDelimitedItemList(_str list, _str delimiter, boolean allowDuplicates = false, _str lockedItems = '')
{
// remove previous list items
p_window_id._TreeDelete(TREE_ROOT_INDEX, 'C');
_str node;
int newIndex;
for(;;) {
if(lockedItems == '') {
break;
}
parse lockedItems with node (delimiter) lockedItems;
if(node != '') {
// make sure the node isnt already in the tree if duplicates are not allowed
if(!allowDuplicates && p_window_id._TreeSearch(TREE_ROOT_INDEX, node) >= 0) {
continue;
}
newIndex = p_window_id._TreeAddListItem(node);
p_window_id._TreeSetInfo(newIndex, 0, -1, -1, TREENODE_BOLD);
}
}
for(;;) {
if(list == '') {
break;
}
parse list with node (delimiter) list;
if(node != '') {
// make sure the node isnt already in the tree if duplicates are not allowed
if(!allowDuplicates && p_window_id._TreeSearch(TREE_ROOT_INDEX, node) >= 0) {
continue;
}
p_window_id._TreeAddListItem(node);
}
}
if (p_window_id.p_EditInPlace && p_window_id.p_enabled) {
// add the node for new data
newIndex = p_window_id._TreeAddListItem(BLANK_TREE_NODE_MSG);
p_window_id._TreeSetInfo(newIndex, 0, -1, -1, TREENODE_BOLD);
}
}
/**
* Maybe generate a makefile for the specified project. The
* name of the makefile will be read from the project file. If
* there is no name defined, it will not be generated.
*
* @param projectName
* Name of the project to generate a makefile for
*/
void _maybeGenerateMakefile(_str projectName = _project_name)
{
int projectHandle = _ProjectHandle(projectName);
// if there is a makefile defined in the project, update it if anything changed
_str buildSystem = _ProjectGet_BuildSystem(projectHandle);
_str makefile = _ProjectGet_BuildMakeFile(projectHandle);
if(strieq(buildSystem, "automakefile") && makefile != "") {
//say("regenerate makefile: filemod=" fileListModified " toolmod=" toolListModified);
generate_makefile(projectName, makefile, false, false);
}
}
/**
* Converts a space delimited list of files to semicolons. If the input list already
* has semicolons, the list is return unchanged.
*
* @param result
*
* @return
*/
_str _SpaceDelimitedFileList(_str FileList)
{
if (!pos(';',FileList)) {
return(FileList);
}
_str result='';
for (;;) {
if (FileList=='') {
break;
}
_str file='';
parse FileList with file';' FileList;
if (file!='') {
if (result=='') {
result=maybe_quote_filename(file);
} else {
result=result:+' ':+maybe_quote_filename(file);
}
}
}
return(result);
}
/**
* Converts a space delimited list of files to semicolons. If the input list already
* has semicolons, the list is return unchanged.
*
* @param result
*
* @return
*/
_str _SemicolonDelimitedFileList(_str FileList)
{
if (pos(';',FileList)){
return(FileList);
}
_str semicolons_result='';
for (;;) {
if (FileList=='') {
break;
}
_str file=parse_file(FileList,false);
if (file!='') {
if (semicolons_result=='') {
semicolons_result=file;
} else {
semicolons_result=semicolons_result:+';':+file;
}
}
}
return(semicolons_result);
}
static void resizeProjectProperties(int &tabWidth, int &tabHeight)
{
// get form width and height in twips
form_width := _dx2lx(SM_TWIP,p_active_form.p_client_width);
form_height := _dy2ly(SM_TWIP,p_active_form.p_client_height);
border_width := p_active_form.p_width - form_width;
border_height := p_active_form.p_height - form_height;
// make sure the form is big enough
if (form_width < ctlfolders.p_x + ctlfolders.p_width + _ok.p_width) {
p_active_form.p_width = ctlfolders.p_x + ctlfolders.p_width + _ok.p_width - border_width;
form_width = _dx2lx(SM_TWIP,p_active_form.p_client_width);
}
if (form_height < ctlBuildSystem.p_height*3) {
p_active_form.p_height = ctlBuildSystem.p_height*3 + border_height;
form_height = _dy2ly(SM_TWIP,p_active_form.p_client_height);
}
// border/padding constants for spacing controls
pad_x := _ok.p_x;
pad_y := ctlconfigurations.p_y;
// resizing configurations combo box and button
ctlCurConfig.p_width = form_width - ctlCurConfig.p_x - ctlconfigurations.p_width - pad_x*3;
ctlconfigurations.p_x = form_width - ctlconfigurations.p_width - pad_x;
// resize main tab control
_proj_prop_sstab.p_width = form_width - _proj_prop_sstab.p_x;
_proj_prop_sstab.p_height = form_height - _proj_prop_sstab.p_y - _ok.p_height - pad_y*3;
// position buttons
_ok.p_y = form_height - _ok.p_height - pad_y;
_opencancel.p_y = _ok.p_y;
ctlhelp.p_y = _ok.p_y;
ctlfolders.p_y = _ok.p_y;
// get tab control client area width and height
tabWidth = _proj_prop_sstab.p_width;
tabHeight = _proj_prop_sstab.p_height - _add.p_height;
}
static void resizeFilesTab(int width, int height)
{
pad_x := _srcfile_list.p_x;
pad_y := 60;
_srcfile_list.p_width = width - _add.p_width - pad_x*5;
_project_nofselected.p_x - _srcfile_list.p_x + _srcfile_list.p_width - _project_nofselected.p_width;
_srcfile_list.p_height = height - _srcfile_list.p_y - pad_y;
ctlimport.p_y = height - ctlimport.p_height - pad_y;
_add.p_x = width - _add.p_width - pad_x*2;
_addtree.p_x = _add.p_x;
ctladdwildcard.p_x = _add.p_x;
_invert.p_x = _add.p_x;
_remove.p_x = _add.p_x;
_remove_all.p_x = _add.p_x;
ctlrefresh.p_x = _add.p_x;
ctlproperties.p_x = _add.p_x;
ctlimport.p_x = _add.p_x;
}
static void resizeDirectoriesTab(int width, int height)
{
pad_x := _ok.p_x;
pad_y := 60;
_prjworking_dir.p_width = width - _prjworking_dir.p_x - _browsedir1.p_width - _projworking_button.p_width - pad_x*4;
_browsedir1.p_x = _prjworking_dir.p_x + _prjworking_dir.p_width + pad_x;
_projworking_button.p_x = _browsedir1.p_x + _browsedir1.p_width + pad_x;
_prjref_files.p_width = _prjworking_dir.p_width;
_browserefs.p_x = _browsedir1.p_x;
_projref_button.p_x = _projworking_button.p_x;
height -= ctlHelpLabelDir.p_height + pad_y;
ctlHelpLabelDir.p_y = height;
ctlHelpLabelDir.p_width = width - ctlHelpLabelDir.p_x*2;
ctlUserIncludesList.p_width = width - ctlUserIncludesList.p_x - _projworking_button.p_width - pad_x*3;
ctlUserIncludesList.p_height = height - ctlUserIncludesList.p_y - pad_y;
ctlBrowseUserIncludes.p_x = _projworking_button.p_x;
ctlMoveUserIncludesUp.p_x =_projworking_button.p_x;
ctlMoveUserIncludesDown.p_x = _projworking_button.p_x;
}
static void resizeToolsTab(int width, int height)
{
pad_x := 60;
pad_y := 60;
delta_x := width - ctlToolNew.p_width - pad_x*2 - ctlToolNew.p_x;
delta_y := height - ctlHelpLabelTools.p_height - pad_y - ctlHelpLabelTools.p_y;
ctlHelpLabelTools.p_y += delta_y;
ctlHelpLabelTools.p_width += delta_x;
ctlAppTypeLabel.p_y += delta_y;
ctlAppType.p_y += delta_y;
ctlAppType.p_width += delta_x;
ctlToolHideCombo.p_y += delta_y;
ctlToolSaveCombo.p_y += delta_y;
ctlCaptureOutputFrame.p_y += delta_y;
ctlRunInXterm.p_y += delta_y;
ctlToolBeep.p_y += delta_y;
ctlToolVerbose.p_y += delta_y;
ctlCommandIsSlickCMacro.p_y += delta_y;
ctlBuildFirst.p_y += delta_y;
ctlMenuCaptionLabel.p_y += delta_y;
ctlToolMenuCaption.p_y += delta_y;
ctlToolMenuCaption.p_width += delta_x;
ctlRunFromDirLabel.p_y += delta_y;
ctlRunFromDir.p_y += delta_y;
ctlBrowseRunFrom.p_y += delta_y;
ctlRunFromButton.p_y += delta_y;
ctlRunFromDir.p_width += delta_x;
ctlBrowseRunFrom.p_x += delta_x;
ctlRunFromButton.p_x += delta_x;
ctlcmdmessage.p_y += delta_y;
ctlcommand_line_label.p_y += delta_y;
ctlcommand_options.p_y += delta_y;
ctlToolCmdLine.p_y += delta_y;
ctlBrowseCmdLine.p_y += delta_y;
ctlToolCmdLineButton.p_y += delta_y;
ctlToolCmdLine.p_width += delta_x;
ctlBrowseCmdLine.p_x += delta_x;
ctlToolCmdLineButton.p_x += delta_x;
ctlToolTree.p_width += delta_x;
ctlToolTree.p_height += delta_y;
ctlToolUp.p_x += delta_x;
ctlToolDown.p_x += delta_x;
ctlToolDelete.p_x += delta_x;
ctlToolNew.p_x += delta_x;
ctlToolAdvanced.p_x += delta_x;
}
static void resizeBuildTab(int width, int height)
{
pad_x := 60;
pad_y := 60;
delta_x := width - ctlPreBuildCmdButton.p_width - pad_x*2 - ctlPreBuildCmdButton.p_x;
delta_y := height - ctlBuildSystem.p_height - pad_y - ctlBuildSystem.p_y;
ctlBuildSystem.p_y += delta_y;
ctlBuildSystem.p_width = width - ctlBuildSystem.p_x*2;
ctlAutoMakefile.p_width = width - ctlAutoMakefile.p_x - ctlMakefileLabel.p_x*2;
ctlAutoMakefileButton.p_x = ctlAutoMakefile.p_x + ctlAutoMakefile.p_width + pad_x;
ctlStopOnPreErrors.p_x += delta_x;
ctlPreBuildCmdButton.p_x += delta_x;
ctlMovePreCmdUp.p_x += delta_x;
ctlMovePreCmdDown.p_x += delta_x;
ctlPreBuildCmdList.p_width += delta_x;
ctlStopOnPostErrors.p_x += delta_x;
ctlPostBuildCmdBtn.p_x += delta_x;
ctlMovePostCmdUp.p_x += delta_x;
ctlMovePostCmdDown.p_x += delta_x;
ctlPostBuildCmdList.p_width += delta_x;
half_y := delta_y intdiv 2;
ctlStopOnPostErrors.p_y += half_y;
ctlPostBuildCmdBtn.p_y += half_y;
ctlMovePostCmdUp.p_y += half_y;
ctlMovePostCmdDown.p_y += half_y;
ctlPostBuildCmdList.p_y += half_y;
ctlPostBuildLabel.p_y += half_y;
ctlPostBuildCmdList.p_height += half_y;
ctlPreBuildCmdList.p_height += half_y;
}
static void resizeCompileTab(int width, int height)
{
pad_x := 60;
pad_y := 60;
delta_y := height - ctlHelpLabelCompileLink.p_height - pad_y - ctlHelpLabelCompileLink.p_y;
ctlCompilerList.p_width = width - ctlCompilerList.p_x - ctlcompiler_config.p_width - pad_x*3;
ctlcompiler_config.p_x = width - ctlcompiler_config.p_width - pad_x*2;
ctlDefinesTree.p_width = ctlCompilerList.p_width;
ctlDefinesTree.p_height += delta_y;
ctlAddDefine.p_x = ctlcompiler_config.p_x;
ctlAddUndef.p_x = ctlcompiler_config.p_x;
ctlLibraries.p_width = ctlCompilerList.p_width - ctlLinkOrder.p_width - pad_x;
ctlLinkOrder.p_x = ctlCompilerList.p_x + ctlCompilerList.p_width - ctlLinkOrder.p_width;
ctlLibrariesButton.p_x = ctlcompiler_config.p_x;
ctlLibraries.p_y += delta_y;
ctlLinkOrder.p_y += delta_y;
ctlLibrariesButton.p_y += delta_y;
ctlHelpLabelCompileLink.p_y += delta_y;
ctlHelpLabelCompileLink.p_width = width - ctlHelpLabelCompileLink.p_x*2;
}
static void resizeDependenciesTab(int width, int height)
{
ctlDepsTree.p_width = width - ctlDepsTree.p_x*2;
ctlDepsTree.p_height = height - ctlDepsTree.p_y*2;
}
static void resizeOpenTab(int width, int height)
{
list1.p_width = width - list1.p_x*2;
list1.p_height = height - ctlHelpLabelOpenCmd.p_height - list1.p_y*3;
ctlHelpLabelOpenCmd.p_width = width - ctlHelpLabelOpenCmd.p_x*2;
ctlHelpLabelOpenCmd.p_y = height - ctlHelpLabelOpenCmd.p_height - list1.p_y;
}
void _project_form.on_resize()
{
resizeProjectProperties(auto tabWidth, auto tabHeight);
resizeFilesTab(tabWidth, tabHeight);
resizeDirectoriesTab(tabWidth, tabHeight);
resizeToolsTab(tabWidth, tabHeight);
resizeBuildTab(tabWidth, tabHeight);
resizeCompileTab(tabWidth, tabHeight);
resizeDependenciesTab(tabWidth, tabHeight);
resizeOpenTab(tabWidth, tabHeight);
}
defeventtab _file_properties_form;
void ctlok.on_create(WILDCARD_FILE_ATTRIBUTES f,_str filespec='',_str FormCaption='')
{
//ctlfilespec.p_text=_SemicolonDelimitedFileList(filespec);
ctlfilespec.p_text=filespec;
if (FormCaption!='') {
p_active_form.p_caption=FormCaption;
} else {
ctlfilespec.p_enabled=false;
ctlfilespec.p_prev.p_enabled=false;
}
ctlrecurse.p_value=(int)f.Recurse;
ctlrefilter.p_value=(int)f.Refilter;
//ctlexcludes.p_text=_SemicolonDelimitedFileList(f.Excludes);
ctlexcludes.p_text=f.Excludes;
}
void ctlok.lbutton_up()
{
WILDCARD_FILE_ATTRIBUTES result;
//result.Excludes=_SpaceDelimitedFileList(ctlexcludes.p_text);
result.Excludes=ctlexcludes.p_text;
result.Recurse=ctlrecurse.p_value!=0;
result.Refilter=ctlrefilter.p_value!=0;
_param1=ctlfilespec.p_text;
if (!iswildcard(_param1)) {
_message_box('There are no wildcard character in this filespec');
return;
}
//_param1=_SpaceDelimitedFileList(_param1);
_param2=result;
p_active_form._delete_window(0);
}
defeventtab _import_list_form;
void _init_filters()
{
p_cb_list_box._lbclear();
p_cb_list_box._retrieve_list();
p_cb_list_box._lbbottom();
_str name='';
_str list='';
_str wildcards=def_file_types;
for (;;) {
parse wildcards with name '('list')' ',' wildcards;
if (name=='') break;
p_cb_list_box._lbadd_item(list);
}
}
ctlok.on_create()
{
_retrieve_prev_form();
ctlFileFilter._init_filters();
ctlFileFilter.p_enabled=ctlFileFilterEnable.p_value!=0;
}
ctlFileFilterEnable.lbutton_up()
{
ctlFileFilter.p_enabled=ctlFileFilterEnable.p_value!=0;
}
ctlListFileBrowse.lbutton_up()
{
_str result=_OpenDialog("-modal "_stdform("_open_form"),
'Import Files',// title
'',// Initial wildcards
"Text Files (*.txt),All Files (*.*)",
OFN_NOCHANGEDIR|OFN_FILEMUSTEXIST|OFN_ALLOWMULTISELECT|OFN_SET_LAST_WILDCARDS,
"", // Default extension
""/*wildcards*/, // Initial filename
"",// Initial directory
"",
""
);
if ( result!='' ) {
ctlListFile.p_text=result;
}
}
static int get_file_array(_str (&file_array)[],boolean &recursive)
{
file_array._makeempty();
// collapse the list file into a bgm_gen_file_list friendly string
int temp_wid;
int orig_wid;
int status=_open_temp_view(ctlListFile.p_text,temp_wid,orig_wid);
if (status) {
_message_box('Could not open list file');
return status;
}
if (p_Noflines+10>_default_option(VSOPTION_WARNING_ARRAY_SIZE)) {
_default_option(VSOPTION_WARNING_ARRAY_SIZE,p_Noflines+10);
}
top();
up();
_str cur_line;
while (!down()) {
get_line(cur_line);
cur_line=strip(cur_line);
if (cur_line:!='') {
file_array[file_array._length()]=cur_line;
}
}
p_window_id=orig_wid;
_delete_temp_view(temp_wid);
recursive=ctlRecurse.p_value!=0;
return 0;
}
static int generate_file_list()
{
_str file_array[];
boolean recursive;
int status=get_file_array(file_array,recursive);
if (status) {
return 0;
}
_str wildcards=ALLFILES_RE;
if (ctlFileFilterEnable.p_value) {
wildcards=ctlFileFilter.p_cb_text_box.p_text;
}
int temp_wid;
status=bgm_gen_file_list(temp_wid,'',wildcards,'',true,false,false,true,recursive,file_array);
if (status) {
if (status<0) {
_message_box(get_message(status));
}
return(0);
}
activate_window(temp_wid);
bgm_filter_project_files(wildcards);
return temp_wid;
}
ctlok.lbutton_up()
{
_save_form_response();
if (ctlFileFilter.p_text!='') {
_append_retrieve(ctlFileFilter,ctlFileFilter.p_text);
}
p_active_form._delete_window(generate_file_list());
}
boolean def_project_auto_build = false;
static _str _pending_builds:[];
static boolean _in_build = false;
static boolean _disable_auto_builds = false; //temporarily disable
#define AUTOBUILD_TIMER_INTERVAL 500
static int _gAutoBuildTimerHandle = -2;
_command void project_toggle_auto_build()
{
def_project_auto_build = !def_project_auto_build;
if (!def_project_auto_build) {
_pending_builds._makeempty();
}
}
int _OnUpdate_project_toggle_auto_build(CMDUI &cmdui,int target_wid,_str command)
{
return(def_project_auto_build ? MF_ENABLED|MF_CHECKED : MF_ENABLED);
}
void _cb_auto_build_timer()
{
if (_in_build) {
return;
}
_next_pending_build();
if (!_in_build && _pending_builds._isempty()) {
_kill_timer(_gAutoBuildTimerHandle);
_gAutoBuildTimerHandle = -2;
}
}
// on save callback
void _cbsave_project_auto_build()
{
if (_workspace_filename != '' && def_project_auto_build && !_disable_auto_builds && !debug_active()) {
_str projName = _WorkspaceFindProjectWithFile(p_buf_name, _workspace_filename, true, true);
if (projName != "") {
//say('_cbsave_project_auto_build: 'p_buf_name' -> 'projName);
if (!_pending_builds._indexin(projName)) {
_pending_builds:[projName] = 1;
if (_gAutoBuildTimerHandle < 0) {
_gAutoBuildTimerHandle = _set_timer(AUTOBUILD_TIMER_INTERVAL, _cb_auto_build_timer);
}
}
}
}
}
// on stop process callback
void _cbstop_process_cancel_pending_builds()
{
_clear_pending_builds();
}
// on workspace closed callback
void _wkspace_close_cancel_pending_builds()
{
_clear_pending_builds();
}
// prebuild callback
void _prebuild_check_start()
{
//say('_prebuild_check_started 'arg(1));
_in_build = true; // start timer
}
// postbuild callback
void _postbuild_build_done()
{
//say('_postbuild_check_build_done 'arg(1));
_in_build = false;
}
static void _clear_pending_builds()
{
_pending_builds._makeempty();
_in_build = false;
if (_gAutoBuildTimerHandle > 0) {
_kill_timer(_gAutoBuildTimerHandle);
_gAutoBuildTimerHandle = -2;
}
}
static void _next_pending_build()
{
//say('_next_pending_build ');
_str projName;
projName._makeempty();
_pending_builds._nextel(projName);
if (!projName._isempty()) {
_execute_pending_auto_build(projName);
} else {
_clear_pending_builds();
}
}
static void _execute_pending_auto_build(_str projName)
{
//say('_execute_pending_auto_build: 'projName);
if (_workspace_filename != '') {
_str cmd = "project-build";
_str old_project_name = _project_name;
boolean old_process_output = def_process_tab_output;
def_process_tab_output = true; // auto builds work quietly
workspace_set_active(projName, false, false, false);
execute(cmd);
workspace_set_active(old_project_name, false, false, false);
def_process_tab_output = old_process_output;
}
if (_pending_builds._indexin(projName)) {
_pending_builds._deleteel(projName);
}
}
void _project_disable_auto_build(boolean enable)
{
_disable_auto_builds = enable;
}
definit()
{
_disable_auto_builds = false;
_pending_builds._makeempty();
_in_build = false;
_gAutoBuildTimerHandle = -2;
}