void
CBFileHistoryMenu::CBFileHistoryMenuX
	(
	const CBDocumentManager::FileHistoryType type
	)
{
	if (type == CBDocumentManager::kProjectFileHistory)
		{
		JXImage* icon = new JXImage(GetDisplay(), jcc_project_file);
		assert( icon != NULL );
		SetDefaultIcon(icon, kJTrue);
		}

	CBFileHistoryMenu* master =
		(CBGetDocumentManager())->GetFileHistoryMenu(itsDocType);
	if (master != NULL)
		{
		std::ostringstream data;
		master->WriteSetup(data);
		const std::string s = data.str();
		std::istringstream input(s);
		ReadSetup(input);
		}

	ListenTo(this);
	ListenTo(CBGetDocumentManager());
}
CBStringCompleter::CBStringCompleter
	(
	const CBLanguage	lang,
	const JSize			keywordCount,
	const JCharacter**	keywordList,
	const JBoolean		caseSensitive
	)
	:
	itsLanguage(lang),
	itsPredefKeywordCount(keywordCount),
	itsPrefefKeywordList(keywordList),
	itsCaseSensitiveFlag(caseSensitive)
{
	itsStringList = new JPtrArray<JString>(JPtrArrayT::kForgetAll, 1000);
	assert( itsStringList != NULL );
	itsStringList->SetSortOrder(JOrderedSetT::kSortAscending);

	if (itsCaseSensitiveFlag)
		{
		itsStringList->SetCompareFunction(JCompareStringsCaseSensitive);
		}
	else
		{
		itsStringList->SetCompareFunction(JCompareStringsCaseInsensitive);
		}

	itsOwnedList = new JPtrArray<JString>(JPtrArrayT::kDeleteAll);
	assert( itsOwnedList != NULL );

	if (itsLanguage != kCBOtherLang)
		{
		ListenTo(CBGetDocumentManager());
		}

	CBGetStyler(lang, &itsStyler);
	UpdateWordList();
	if (itsStyler != NULL)
		{
		ListenTo(itsStyler);
		}

	// We are constructed at a random point in time, so we have to
	// ListenTo() all pre-existing project documents.

	JPtrArray<CBProjectDocument>* docList =
		(CBGetDocumentManager())->GetProjectDocList();

	const JSize docCount = docList->GetElementCount();
	for (JIndex i=1; i<=docCount; i++)
		{
		ListenTo(((docList->NthElement(i))->GetSymbolDirector())->GetSymbolList());
		}
}
void
CBFileHistoryMenu::Receive
	(
	JBroadcaster*	sender,
	const Message&	message
	)
{
	if (sender == this && message.Is(JXMenu::kItemSelected))
		{
		const JXMenu::ItemSelected* selection =
			dynamic_cast<const JXMenu::ItemSelected*>(&message);
		assert( selection != NULL );

		// need copy because menu will change
		const JString fileName = GetFile(selection->GetIndex());

		JBoolean saveReopen = CBProjectDocument::WillReopenTextFiles();
		if (((GetDisplay())->GetLatestKeyModifiers()).GetState(kJXShiftKeyIndex))
			{
			CBProjectDocument::ShouldReopenTextFiles(!saveReopen);
			}

		CBDocumentManager* docMgr = CBGetDocumentManager();
		if (!((GetDisplay())->GetLatestKeyModifiers()).meta() ||
			(docMgr->CloseProjectDocuments() &&
			 docMgr->CloseTextDocuments()))
			{
			docMgr->OpenSomething(fileName);
			}

		CBProjectDocument::ShouldReopenTextFiles(saveReopen);
		}

	else if (sender == CBGetDocumentManager() &&
			 message.Is(CBDocumentManager::kAddFileToHistory))
		{
		const CBDocumentManager::AddFileToHistory* info =
			dynamic_cast<const CBDocumentManager::AddFileToHistory*>(&message);
		assert( info != NULL );
		if (itsDocType == info->GetType())
			{
			AddFile(info->GetFullName());
			}
		}

	else
		{
		JXFileHistoryMenu::Receive(sender, message);
		}
}
示例#4
0
void
CBFileNode::OpenComplementFile()
	const
{
	JString fullName;
	if (GetFullName(&fullName))
		{
		const CBTextFileType type = (CBGetPrefsManager())->GetFileType(fullName);
		if (type == kCBHTMLFT || type == kCBXMLFT)
			{
			(JXGetWebBrowser())->ShowFileContent(fullName);
			}
		else
			{
			(CBGetDocumentManager())->OpenComplementFile(fullName, type);
			}
		}
	else
		{
		JString msg = "Unable to find complement of \"";
		msg += GetFileName();
		msg.AppendCharacter('"');
		(JGetUserNotification())->ReportError(msg);
		}
}
示例#5
0
JBoolean
CBFileNode::ParseFiles
	(
	CBFileListTable*			parser,
	const JPtrArray<JString>&	allSuffixList,
	CBSymbolList*				symbolList,
	CBCTree*					cTree,
	CBJavaTree*					javaTree,
	CBPHPTree*					phpTree,
	JProgressDisplay&			pg
	)
	const
{
	JString fullName, trueName;
	if (GetFullName(&fullName) && JGetTrueName(fullName, &trueName))
		{
		if (!ParseFile(trueName, parser, allSuffixList, symbolList, cTree, javaTree, phpTree, pg))
			{
			return kJFalse;
			}

		const CBTextFileType type = (CBGetPrefsManager())->GetFileType(trueName);
		if ((CBGetDocumentManager())->GetComplementFile(trueName, type, &fullName,
														GetProjectDoc(), kJFalse) &&
			JGetTrueName(fullName, &trueName) &&
			!ParseFile(trueName, parser, allSuffixList, symbolList, cTree, javaTree, phpTree, pg))
			{
			return kJFalse;
			}
		}
	return CBFileNodeBase::ParseFiles(parser, allSuffixList, symbolList, cTree, javaTree, phpTree, pg);
}
void
CBSearchTextDialog::UpdateDisplay()
{
	JXSearchTextDialog::UpdateDisplay();

	if (itsFileList->GetRowCount() == 0)
		{
		itsMultifileCB->SetState(kJFalse);
		}

	if (itsMultifileCB->IsChecked() || itsSearchDirCB->IsChecked())
		{
		GetFindBackButton()->Deactivate();
		GetReplaceButton()->Deactivate();
		GetReplaceFindFwdButton()->Deactivate();
		GetReplaceFindBackButton()->Deactivate();
		GetReplaceAllBackButton()->Deactivate();
		GetReplaceAllInSelButton()->Deactivate();

		// These two buttons will already be deactivated if !HasSearchText().

		if (HasSearchText())
			{
			GetFindFwdButton()->Activate();

			if ((CBGetDocumentManager())->WillEditTextFilesLocally())
				{
				GetReplaceAllFwdButton()->Activate();
				}
			}
		}
}
void
CBStringCompleter::CopySymbolsForLanguage
	(
	const CBLanguage lang
	)
{
	JPtrArray<CBProjectDocument>* docList =
		(CBGetDocumentManager())->GetProjectDocList();

	const JSize docCount = docList->GetElementCount();
	for (JIndex i=1; i<=docCount; i++)
		{
		const CBSymbolList* symbolList =
			((docList->NthElement(i))->GetSymbolDirector())->GetSymbolList();

		const JSize symbolCount = symbolList->GetElementCount();
		for (JIndex j=1; j<=symbolCount; j++)
			{
			CBLanguage l;
			CBSymbolList::Type type;
			JBoolean fullyQualifiedFileScope;
			const JString& symbolName =
				symbolList->GetSymbol(j, &l, &type, &fullyQualifiedFileScope);
			if (l == lang && !fullyQualifiedFileScope)
				{
				Add(const_cast<JString*>(&symbolName));
				}
			}
		}
}
void
CBCompileDocument::HandleErrorMenu
	(
	const JIndex index
	)
{
	(CBGetDocumentManager())->SetActiveListDocument(this);

	if (index == kFirstErrorCmd)
		{
		ShowFirstError();
		}

	else if (index == kPrevErrorCmd)
		{
		ShowPrevError();
		}
	else if (index == kNextErrorCmd)
		{
		ShowNextError();
		}

	else if (index == kOpenFileCmd)
		{
		GetTextEditor()->OpenSelection();
		}
}
示例#9
0
JBoolean
CBApp::Close()
{
	// --man with no args must leave window open

	if ((CBGetViewManPageDialog())->IsActive())
		{
		return kJFalse;
		}

	CBGetPrefsManager()->SaveProgramState();

	// close these first so they remember all open text documents

	if (!(CBGetDocumentManager())->CloseProjectDocuments())
		{
		return kJFalse;
		}

	// close everything else

	const JBoolean success = JXApplication::Close();	// deletes us if successful
	if (!success)
		{
		CBGetPrefsManager()->ForgetProgramState();
		}

	return success;
}
示例#10
0
CBCommand::~CBCommand()
{
	if (itsParent != NULL && itsParent->itsBuildOutputDoc == NULL)
		{
		itsParent->itsBuildOutputDoc = itsBuildOutputDoc;
		}
	if (itsParent != NULL && itsParent->itsRunOutputDoc == NULL)
		{
		itsParent->itsRunOutputDoc = itsRunOutputDoc;
		}

	if (itsUpdateSymbolDatabaseFlag && itsSuccessFlag)
		{
		(CBGetDocumentManager())->UpdateSymbolDatabases();
		}

	// only refresh VCS status when all finished, since may be expensive

	if (itsParent != NULL && itsRefreshVCSStatusFlag)
		{
		itsParent->itsRefreshVCSStatusFlag = kJTrue;
		}
	else if (itsRefreshVCSStatusFlag)
		{
		(CBGetDocumentManager())->RefreshVCSStatus();
		}

	if (itsParent != NULL && itsCallParentProcessFinishedFlag)
		{
		itsParent->ProcessFinished(itsSuccessFlag, itsCancelledFlag);
		}
	Broadcast(Finished(itsSuccessFlag, itsCancelledFlag));

	const JSize count = itsCmdList->GetElementCount();
	for (JIndex i=1; i<=count; i++)
		{
		CmdInfo info = itsCmdList->GetElement(i);
		info.Free(kJTrue);
		}
	jdelete itsCmdList;

	if (itsParent == NULL)
		{
		FinishWindow(&itsBuildOutputDoc);
		FinishWindow(&itsRunOutputDoc);
		}
}
void
CBSearchTextDialog::OpenSelectedFiles()
	const
{
	JPtrArray<JString> fileList(JPtrArrayT::kDeleteAll);
	if (itsFileList->GetSelection(&fileList))
		{
		(CBGetDocumentManager())->OpenSomething(fileList);
		}
}
示例#12
0
void
CBApp::CollectSearchPaths
	(
	CBDirInfoList* searchPaths
	)
	const
{
	searchPaths->DeleteAll();
	searchPaths->SetCompareFunction(CBDirInfo::ComparePathNames);

	JPtrArray<CBProjectDocument>* docList =
		(CBGetDocumentManager())->GetProjectDocList();

	const JSize docCount = docList->GetElementCount();
	JString truePath;
	JBoolean recurse;
	for (JIndex j=1; j<=docCount; j++)
		{
		CBProjectDocument* doc   = docList->NthElement(j);
		const CBDirList& dirList = doc->GetDirectories();
		const JSize count        = dirList.GetElementCount();
		for (JIndex i=1; i<=count; i++)
			{
			if (dirList.GetTruePath(i, &truePath, &recurse))
				{
				CBDirInfo newInfo(jnew JString(truePath), recurse);
				assert( newInfo.path != NULL );
				newInfo.projIndex = j;

				JBoolean found;
				const JIndex index =
					searchPaths->SearchSorted1(newInfo, JOrderedSetT::kAnyMatch, &found);
				if (found)
					{
					// compute OR of recurse flags

					CBDirInfo existingInfo = searchPaths->GetElement(index);
					if (newInfo.recurse && !existingInfo.recurse)
						{
						existingInfo.recurse = kJTrue;
						searchPaths->SetElement(index, existingInfo);
						}
					jdelete newInfo.path;
					}
				else
					{
					searchPaths->InsertElementAtIndex(index, newInfo);
					}
				}
			}
		}

	searchPaths->SetCompareFunction(CBDirInfo::CompareProjIndex);
	searchPaths->Sort();
}
CBSearchDocument::CBSearchDocument
	(
	const JBoolean		isReplace,
	const JBoolean		onlyListFiles,
	const JSize			fileCount,
	JProcess*			p,
	const int			fd,
	const JCharacter*	windowTitle
	)
	:
	CBExecOutputDocument(kCBSearchOutputFT, kCBSearchFilesHelpName, kJFalse, kJFalse),
	itsIsReplaceFlag(isReplace),
	itsOnlyListFilesFlag(onlyListFiles),
	itsReplaceTE(NULL)
{
	itsFoundFlag       = kJFalse;
	itsPrevQuoteOffset = 0;

	JXWidget::HSizingOption hSizing;
	JXWidget::VSizingOption vSizing;
	GetFileDisplayInfo(&hSizing, &vSizing);

	itsIndicator =
		jnew JXProgressIndicator(GetWindow(), hSizing, vSizing,
								 -1000, -1000, 500, kIndicatorHeight);
	assert( itsIndicator != NULL );
	itsIndicator->SetMaxValue(fileCount);

	JXMenuBar* menuBar = GetMenuBar();
	itsMatchMenu = InsertTextMenu(kMatchMenuTitleStr);
	itsMatchMenu->SetMenuItems(kMatchMenuStr, "CBSearchDocument");
	itsMatchMenu->SetUpdateAction(JXMenu::kDisableNone);
	itsMatchMenu->Deactivate();
	ListenTo(itsMatchMenu);

	// allow Meta-_ to parallel Shift key required for Meta-plus

	JXKeyModifiers modifiers(GetDisplay());
	modifiers.SetState(kJXMetaKeyIndex, kJTrue);
	GetWindow()->InstallMenuShortcut(itsMatchMenu, kPrevMatchCmd, '_', modifiers);

	GetWindow()->SetWMClass(CBGetWMClassInstance(), CBGetSearchOutputWindowClass());

	SetConnection(p, fd, ACE_INVALID_HANDLE,
				  windowTitle, JGetString("NoCloseWhileSearching::CBSearchDocument"),
				  "/", windowTitle, kJFalse);

	(CBGetDocumentManager())->SetActiveListDocument(this);

	if (itsIsReplaceFlag)
		{
		itsReplaceTE = jnew CBSearchTE;
		assert( itsReplaceTE != NULL );
		}
}
void
CBSearchTextDialog::UpdateBasePath()
{
	CBProjectDocument* doc;
	if ((CBGetDocumentManager())->GetActiveProjectDocument(&doc))
		{
		itsDirInput->SetBasePath(doc->GetFilePath());
		}
	else
		{
		itsDirInput->ClearBasePath();
		}
}
示例#15
0
JBoolean
CBCClass::ViewDeclaration
	(
	const JCharacter*	fnName,
	const JBoolean		caseSensitive,
	const JBoolean		reportNotFound
	)
	const
{
	JBoolean found = kJFalse;

	JString headerName;
	if (!Implements(fnName, caseSensitive))
		{
		found = ViewInheritedDeclaration(fnName, caseSensitive, reportNotFound);
		if (!found && reportNotFound)
			{
			JString msg = "Unable to find any declaration for \"";
			msg += fnName;
			msg += "\".";
			(JGetUserNotification())->ReportError(msg);
			}
		}
	else if (GetFileName(&headerName))
		{
		CBDocumentManager* docMgr = CBGetDocumentManager();

		JIndex lineIndex;
		if (docMgr->SearchFile(headerName, fnName, caseSensitive, &lineIndex))
			{
			docMgr->OpenTextDocument(headerName, lineIndex);
			found = kJTrue;
			}
		else if (reportNotFound)
			{
			JString msg = "Unable to find the declaration of \"";
			msg += fnName;
			msg += "\".";
			(JGetUserNotification())->ReportError(msg);
			}
		}
	else if (reportNotFound)
		{
		JString msg = GetFullName();
		msg.PrependCharacter('"');
		msg += "\" is a ghost class, so no information is available for it.";
		(JGetUserNotification())->ReportError(msg);
		}

	return found;
}
示例#16
0
void
CBCClass::ViewHeader()
	const
{
	JString headerName;
	if (GetFileName(&headerName))
		{
		(CBGetDocumentManager())->OpenTextDocument(headerName);
		}
	else
		{
		(JGetUserNotification())->ReportError("Ghost classes cannot be opened.");
		}
}
void
CBSymbolTable::DisplaySelectedSymbols()
	const
{
	itsKeyBuffer.Clear();

	const JTableSelection& s = GetTableSelection();
	if (s.HasSelection())
		{
		JString missingFiles;

		JTableSelectionIterator iter(&s);
		JPoint cell;
		while (iter.Next(&cell))
			{
			const JIndex symbolIndex = CellToSymbolIndex(cell);
			JIndex lineIndex;
			const JString& fileName =
				itsSymbolList->GetFile(symbolIndex, &lineIndex);

			CBTextDocument* doc;
			if ((CBGetDocumentManager())->OpenTextDocument(fileName, lineIndex, &doc))
				{
				CBLanguage lang;
				CBSymbolList::Type type;
				itsSymbolList->GetSymbol(symbolIndex, &lang, &type);

				if (CBSymbolList::ShouldSmartScroll(type))
					{
					(doc->GetTextEditor())->ScrollForDefinition(lang);
					}
				}
			else
				{
				missingFiles += fileName;
				missingFiles += "\n";
				}
			}

		if (!missingFiles.IsEmpty())
			{
			const JCharacter* map[] =
				{
				"list", missingFiles
				};
			const JString msg = JGetString(kMissingFilesID, map, sizeof(map));
			(JGetUserNotification())->ReportError(msg);
			}
		}
}
示例#18
0
void
CBFileNode::OpenFile()
	const
{
	JString fullName;
	if (GetFullName(&fullName))
		{
		(CBGetDocumentManager())->OpenSomething(fullName);
		}
	else
		{
		ReportNotFound();
		}
}
void
CBStringCompleter::Receive
	(
	JBroadcaster*	sender,
	const Message&	message
	)
{
	if (sender == CBGetDocumentManager() &&
		message.Is(CBDocumentManager::kProjectDocumentCreated))
		{
		const CBDocumentManager::ProjectDocumentCreated* info =
			dynamic_cast<const CBDocumentManager::ProjectDocumentCreated*>(&message);
		UpdateWordList();
		ListenTo(((info->GetProjectDocument())->GetSymbolDirector())->GetSymbolList());
		}
	else if (sender == CBGetDocumentManager() &&
			 message.Is(CBDocumentManager::kProjectDocumentDeleted))
		{
		UpdateWordList();
		}

	else if (message.Is(CBSymbolList::kChanged))
		{
		UpdateWordList();
		}

	else if (sender == itsStyler && message.Is(CBStylerBase::kWordListChanged))
		{
		UpdateWordList();
		}

	else
		{
		JBroadcaster::Receive(sender, message);
		}
}
void
CBSearchTextDialog::SaveFileForSearch
	(
	const JString&		fullName,
	JPtrArray<JString>*	fileList,
	JPtrArray<JString>*	nameList
	)
	const
{
	JBoolean exists;
	const JIndex index =
		nameList->GetInsertionSortIndex(const_cast<JString*>(&fullName), &exists);
	if (!exists)
		{
		JString* file = jnew JString(fullName);
		assert( file != NULL );

		JXFileDocument* doc;
		if ((CBGetDocumentManager())->FileDocumentIsOpen(*file, &doc) &&
			doc->NeedsSave())
			{
			CBTextDocument* textDoc = dynamic_cast<CBTextDocument*>(doc);
			if (textDoc != NULL &&
				(JCreateTempFile(file)).OK())
				{
				std::ofstream output(*file);
				((textDoc->GetTextEditor())->GetText()).Print(output);
				}
			}

		if (!file->IsEmpty())
			{
			JString* name = jnew JString(fullName);
			assert( name != NULL );
			nameList->InsertAtIndex(index, name);

			fileList->InsertAtIndex(index, file);
			}
		else
			{
			jdelete file;
			}
		}
}
示例#21
0
JBoolean
CBApp::FindAndViewFile
	(
	const JCharacter*	fileName,
	const JIndexRange	lineRange,		// not reference because of default value
	const JBoolean		caseSensitive
	)
	const
{
	JString fullName;
	if (FindFile(fileName, caseSensitive, &fullName))
		{
		(CBGetDocumentManager())->OpenSomething(fullName, lineRange);
		return kJTrue;
		}
	else
		{
		return kJFalse;
		}
}
示例#22
0
void
CBCClass::ViewSource()
	const
{
	CBDocumentManager* docMgr = CBGetDocumentManager();

	JString headerName;
	if (!GetFileName(&headerName))
		{
		(JGetUserNotification())->ReportError("Ghost classes cannot be opened.");
		}
	else if (GetDeclareType() == kEnumType)
		{
		docMgr->OpenTextDocument(headerName);
		}
	else
		{
		docMgr->OpenComplementFile(headerName, kCBCHeaderFT,
								   (GetTree())->GetProjectDoc());
		}
}
示例#23
0
JBoolean
CBCClass::FindDefinition
	(
	const JString&		headerName,
	const JCharacter*	searchStr,
	const JBoolean		caseSensitive
	)
	const
{
	CBDocumentManager* docMgr = CBGetDocumentManager();
	CBTextDocument* doc       = NULL;

	// look for it in the source file

	JString sourceName;
	JIndex lineIndex;
	if (docMgr->GetComplementFile(headerName, kCBCHeaderFT, &sourceName,
								  (GetTree())->GetProjectDoc()) &&
		docMgr->SearchFile(sourceName, searchStr, caseSensitive, &lineIndex))
		{
		docMgr->OpenTextDocument(sourceName, lineIndex, &doc);
		}

	// look for it in the header file (inline)

	else if (docMgr->SearchFile(headerName, searchStr, caseSensitive, &lineIndex))
		{
		docMgr->OpenTextDocument(headerName, lineIndex, &doc);
		}

	if (doc != NULL)
		{
		(doc->GetTextEditor())->ScrollForDefinition(kCBCLang);
		return kJTrue;
		}
	else
		{
		return kJFalse;
		}
}
void
CBCompileDocument::SetConnection
	(
	JProcess*			p,
	const int			inFD,
	const int			outFD,
	const JCharacter*	windowTitle,
	const JCharacter*	dontCloseMsg,
	const JCharacter*	execDir,
	const JCharacter*	execCmd,
	const JBoolean		showPID
	)
{
	(CBGetDocumentManager())->SetActiveListDocument(this);

	itsPrevLine.Clear();

	if (ShouldClearWhenStart())
		{
		itsHasErrorsFlag = kJFalse;
		}
	if (!itsHasErrorsFlag)
		{
		itsErrorMenu->Deactivate();
		}

	CBExecOutputDocument::SetConnection(p, inFD, outFD, windowTitle,
										dontCloseMsg, execDir, execCmd, kJFalse);

	if (execCmd != NULL)
		{
		CBTextEditor* te = GetTextEditor();
		te->Paste(kDirMarkerStr);
		te->Paste(execDir);
		te->Paste(kDirMarkerEndStr);
		te->Paste("\n\n");
		te->ClearUndo();
		}
}
void
CBEditProjPrefsDialog::UpdateSettings()
{
	(CBGetApplication())->DisplayBusyCursor();

	const JBoolean reopenTextFiles      = itsReopenTextFilesCB->IsChecked();
	const JBoolean doubleSpaceCompile   = itsDoubleSpaceCB->IsChecked();
	const JBoolean rebuildMakefileDaily = itsRebuildMakefileDailyCB->IsChecked();

	const CBProjectTable::DropFileAction dropFileAction =
		(CBProjectTable::DropFileAction) itsDropFileActionRG->GetSelectedItem();

	CBDocumentManager* docMgr             = CBGetDocumentManager();
	JPtrArray<CBProjectDocument>* docList = docMgr->GetProjectDocList();
	const JSize docCount = docList->GetElementCount();

	for (JIndex i=1; i<=docCount; i++)
		{
		(docList->NthElement(i))->
			SetProjectPrefs(reopenTextFiles, doubleSpaceCompile,
							rebuildMakefileDaily, dropFileAction);
		}
}
void
CBJavaTreeDirector::HandleTreeMenu
	(
	const JIndex index
	)
{
	(CBGetDocumentManager())->SetActiveProjectDocument(GetProjectDoc());

	if (index == kEditSearchPathsCmd)
		{
		(GetProjectDoc())->EditSearchPaths(this);
		}
	else if (index == kUpdateCurrentCmd)
		{
		(GetProjectDoc())->UpdateSymbolDatabase();
		}
	else if (index == kForceMinMILinksCmd)
		{
		itsJavaTree->ForceMinimizeMILinks();
		}

	else if (index == kTreeOpenSourceCmd)
		{
		itsJavaTree->ViewSelectedSources();
		}
	else if (index == kTreeOpenFnListCmd)
		{
		itsJavaTree->ViewSelectedFunctionLists();
		}

	else if (index == kTreeCollapseCmd)
		{
		itsJavaTree->CollapseExpandSelectedClasses(kJTrue);
		}
	else if (index == kTreeExpandCmd)
		{
		itsJavaTree->CollapseExpandSelectedClasses(kJFalse);
		}
	else if (index == kTreeExpandAllCmd)
		{
		itsJavaTree->ExpandAllClasses();
		}

	else if (index == kTreeSelParentsCmd)
		{
		itsJavaTree->SelectParents();
		}
	else if (index == kTreeSelDescendantsCmd)
		{
		itsJavaTree->SelectDescendants();
		}
	else if (index == kCopySelNamesCmd)
		{
		itsJavaTree->CopySelectedClassNames();
		}

	else if (index == kFindFnCmd)
		{
		AskForFunctionToFind();
		}
	else if (index == kCloseFnWindCmd)
		{
		CloseFunctionBrowsers();
		}
}
void
CBCompileDocument::ConvertSelectionToFullPath
	(
	JString* fileName
	)
	const
{
	(CBGetDocumentManager())->SetActiveListDocument(const_cast<CBCompileDocument*>(this));

	if (JIsAbsolutePath(*fileName))
		{
		return;
		}

	CBTextEditor* te       = GetTextEditor();
	const JString& text    = te->GetText();
	const JIndex caretChar = te->GetInsertionIndex();

	JArray<JIndexRange> matchList;
	JStack<JIndex, JArray<JIndex> > dirStack;

	JIndex i=1;
	while (dirMarkerPattern.MatchFrom(text, i, &matchList))
		{
		i = (matchList.GetElement(1)).last + 1;
		if (i >= caretChar)
			{
			break;
			}

		if (!(matchList.GetElement(3)).IsEmpty())					// Entering
			{
			dirStack.Push(i);
			}
		else														// Leaving
			{
			assert( !(matchList.GetElement(4)).IsEmpty() );
			JIndex j;
			dirStack.Pop(&j);
			}
		}

	JIndex startChar;
	if (dirStack.Peek(&startChar))
		{
		JIndex endChar = startChar;
		if (text.GetCharacter(endChar) != '\'' &&
			text.LocateNextSubstring("\'", &endChar))
			{
			endChar--;
			JString testName = text.GetSubstring(startChar, endChar);
			testName         = JCombinePathAndName(testName, *fileName);
			if (JFileExists(testName))
				{
				*fileName = testName;
				return;
				}
			}
		}

	CBExecOutputDocument::ConvertSelectionToFullPath(fileName);
}
CBCommandTable::CBCommandTable
	(
	const CBCommandManager::CmdList& cmdList,

	JXTextButton*		addCmdButton,
	JXTextButton*		removeCmdButton,
	JXTextButton*		duplicateCmdButton,
	JXScrollbarSet*		scrollbarSet,
	JXContainer*		enclosure,
	const HSizingOption	hSizing,
	const VSizingOption	vSizing,
	const JCoordinate	x,
	const JCoordinate	y,
	const JCoordinate	w,
	const JCoordinate	h
	)
	:
	JXEditTable(1,1, scrollbarSet, enclosure, hSizing,vSizing, x,y, w,h)
{
	itsTextInput   = NULL;
	itsDNDRowIndex = 0;

	itsCommandXAtom =
		(GetDisplay())->RegisterXAtom(CBCommandSelection::GetCommandXAtomName());

	// font

	(CBGetPrefsManager())->GetDefaultFont(&itsFontName, &itsFontSize);

	const JSize rowHeight = 2*kVMarginWidth + JMax(
		(GetFontManager())->GetLineHeight(JGetDefaultFontName(), kJDefaultFontSize, JFontStyle()),
		(GetFontManager())->GetLineHeight(itsFontName, itsFontSize, JFontStyle()));
	SetDefaultRowHeight(rowHeight);

	// buttons

	itsAddCmdButton       = addCmdButton;
	itsRemoveCmdButton    = removeCmdButton;
	itsDuplicateCmdButton = duplicateCmdButton;

	ListenTo(itsAddCmdButton);
	ListenTo(itsRemoveCmdButton);
	ListenTo(itsDuplicateCmdButton);

	// type menu

	itsOptionsMenu = new JXTextMenu("", this, kFixedLeft, kFixedTop, 0,0, 10,10);
	assert( itsOptionsMenu != NULL );
	itsOptionsMenu->SetToHiddenPopupMenu();
	itsOptionsMenu->SetMenuItems(kOptionsMenuStr);
	itsOptionsMenu->SetUpdateAction(JXMenu::kDisableNone);
	ListenTo(itsOptionsMenu);

	// base path

	CBProjectDocument* doc = NULL;
	if ((CBGetDocumentManager())->GetActiveProjectDocument(&doc))
		{
		itsBasePath = doc->GetFilePath();
		}

	// data

	itsCmdList = new CBCommandManager::CmdList(cmdList);
	assert( itsCmdList != NULL );
	FinishCmdListCopy(itsCmdList);

	for (JIndex i=1; i<=kColCount; i++)
		{
		AppendCols(1, kInitColWidth[i-1]);
		}

	AppendRows(itsCmdList->GetElementCount());

	UpdateButtons();
	ListenTo(&(GetTableSelection()));
}
void
CBCTreeDirector::HandleTreeMenu
	(
	const JIndex index
	)
{
	(CBGetDocumentManager())->SetActiveProjectDocument(GetProjectDoc());

	if (index == kEditCPPMacrosCmd)
		{
		assert( itsEditCPPDialog == NULL );
		itsEditCPPDialog =
			jnew CBEditCPPMacroDialog(this, *(itsCTree->GetCPreprocessor()));
		assert( itsEditCPPDialog != NULL );
		itsEditCPPDialog->BeginDialog();
		ListenTo(itsEditCPPDialog);
		}
	else if (index == kEditSearchPathsCmd)
		{
		GetProjectDoc()->EditSearchPaths(this);
		}
	else if (index == kUpdateCurrentCmd)
		{
		GetProjectDoc()->UpdateSymbolDatabase();
		}
	else if (index == kForceMinMILinksCmd)
		{
		itsCTree->ForceMinimizeMILinks();
		}

	else if (index == kTreeOpenSourceCmd)
		{
		itsCTree->ViewSelectedSources();
		}
	else if (index == kTreeOpenHeaderCmd)
		{
		itsCTree->ViewSelectedHeaders();
		}
	else if (index == kTreeOpenFnListCmd)
		{
		itsCTree->ViewSelectedFunctionLists();
		}

	else if (index == kCreateDerivedClassCmd)
		{
		itsCTree->DeriveFromSelected();
		}

	else if (index == kTreeCollapseCmd)
		{
		itsCTree->CollapseExpandSelectedClasses(kJTrue);
		}
	else if (index == kTreeExpandCmd)
		{
		itsCTree->CollapseExpandSelectedClasses(kJFalse);
		}
	else if (index == kTreeExpandAllCmd)
		{
		itsCTree->ExpandAllClasses();
		}

	else if (index == kTreeSelParentsCmd)
		{
		itsCTree->SelectParents();
		}
	else if (index == kTreeSelDescendantsCmd)
		{
		itsCTree->SelectDescendants();
		}
	else if (index == kCopySelNamesCmd)
		{
		itsCTree->CopySelectedClassNames();
		}

	else if (index == kFindFnCmd)
		{
		AskForFunctionToFind();
		}
	else if (index == kCloseFnWindCmd)
		{
		CloseFunctionBrowsers();
		}
}
void
CBEditTextPrefsDialog::UpdateSettings()
{
	CBTextEditor* te = itsDoc->GetTextEditor();

	JString fontName;
	JSize fontSize;
	itsFontMenu->GetFont(&fontName, &fontSize);
	const JBoolean fontChanged = JI2B(
		fontName != te->GetDefaultFont().GetName() ||
		fontSize != te->GetDefaultFont().GetSize() );

	JFloat vScrollScale = 1.0;
	if (fontChanged)
		{
		const JFontManager* fontMgr = te->GetFontManager();
		const JFloat h1 = te->GetDefaultFont().GetLineHeight();
		const JFloat h2 = fontMgr->GetFont(fontName, fontSize).GetLineHeight();
		vScrollScale    = h2 / h1;
		}

	JInteger tabCharCount;
	JBoolean ok = itsTabCharCountInput->GetValue(&tabCharCount);
	assert( ok );

	JInteger crmLineWidth;
	ok = itsCRMLineWidthInput->GetValue(&crmLineWidth);
	assert( ok );

	JInteger undoDepth;
	ok = itsUndoDepthInput->GetValue(&undoDepth);
	assert( ok );

	JInteger rightMargin;
	ok = itsRightMarginInput->GetValue(&rightMargin);
	assert( ok );

	CBPrefsManager* prefsMgr = CBGetPrefsManager();
	const JBoolean textColorChanged = JNegate(
		itsColor[ CBPrefsManager::kTextColorIndex-1 ] ==
		prefsMgr->GetColor(CBPrefsManager::kTextColorIndex));

	// set colors before RecalcStyles() so stylers update themselves

	prefsMgr->SetDefaultFont(fontName, fontSize);
	for (JIndex j=1; j<=CBPrefsManager::kColorCount; j++)
		{
		prefsMgr->SetColor(j, itsColor[j-1]);
		}

	JPtrArray<CBTextDocument>* docList = (CBGetDocumentManager())->GetTextDocList();
	const JSize docCount = docList->GetElementCount();

	JProgressDisplay* pg = JNewPG();
	pg->FixedLengthProcessBeginning(docCount, "Updating preferences...", kJFalse, kJFalse);

	for (JIndex i=1; i<=docCount; i++)
		{
		CBTextDocument* doc = docList->NthElement(i);

		doc->ShouldMakeBackupFile(itsCreateBackupCB->IsChecked());
		doc->ShouldMakeNewBackupEveryOpen(!itsOnlyBackupIfNoneCB->IsChecked());
		doc->ShouldAllocateTitleSpace(itsExtraSpaceWindTitleCB->IsChecked());
		doc->ShouldOpenComplFileOnTop(itsOpenComplFileOnTopCB->IsChecked());

		te = doc->GetTextEditor();

		if (itsEmulatorIndex != itsOrigEmulatorIndex)
			{
			JTEKeyHandler* handler;
			CBInstallEmulator(kMenuIndexToEmulator[ itsEmulatorIndex-1 ], te, &handler);
			}

		te->ShouldAutoIndent(itsAutoIndentCB->IsChecked());
		te->CBShouldAllowDragAndDrop(itsUseDNDCB->IsChecked());
		te->ShouldMoveToFrontOfText(itsLeftToFrontOfTextCB->IsChecked());

		te->ShouldBalanceWhileTyping(itsBalanceWhileTypingCB->IsChecked());
		te->ShouldScrollToBalance(itsScrollToBalanceCB->IsChecked());
		te->ShouldBeepWhenTypeUnbalanced(itsBeepWhenTypeUnbalancedCB->IsChecked());

		te->TabShouldBeSmart(itsSmartTabCB->IsChecked());
		te->TabShouldInsertSpaces(itsTabToSpacesCB->IsChecked());

		if (fontChanged)
			{
			JXScrollbar *hScrollbar, *vScrollbar;
			const JBoolean ok = te->GetScrollbars(&hScrollbar, &vScrollbar);
			assert( ok );
			vScrollbar->PrepareForScaledMaxValue(vScrollScale);

			te->SetFont(fontName, fontSize, tabCharCount);
			}
		else
			{
			te->SetTabCharCount(tabCharCount);
			}

		te->SetCRMLineWidth(crmLineWidth);
		te->SetUndoDepth(undoDepth);
		te->SetRightMarginWidth(itsRightMarginCB->IsChecked(), rightMargin);

		te->SetDefaultFontStyle(itsColor [ CBPrefsManager::kTextColorIndex-1 ]);
		te->SetBackColor(itsColor [ CBPrefsManager::kBackColorIndex-1 ]);
		te->SetFocusColor(itsColor [ CBPrefsManager::kBackColorIndex-1 ]);
		te->SetCaretColor(itsColor [ CBPrefsManager::kCaretColorIndex-1 ]);
		te->SetSelectionColor(itsColor [ CBPrefsManager::kSelColorIndex-1 ]);
		te->SetSelectionOutlineColor(itsColor [ CBPrefsManager::kSelLineColorIndex-1 ]);
		te->SetRightMarginColor(itsColor [ CBPrefsManager::kRightMarginColorIndex-1 ]);

		if (textColorChanged)
			{
			te->RecalcStyles();
			}

		// force update of insertion font

		JIndex caretIndex;
		if (te->GetCaretLocation(&caretIndex))
			{
			te->SetCaretLocation(caretIndex);
			}

		pg->IncrementProgress();
		}

	CBFnMenuUpdater* updater = CBGetFnMenuUpdater();
	updater->ShouldSortFnNames(itsSortFnMenuCB->IsChecked());
	updater->ShouldIncludeNamespace(itsNSInFnMenuCB->IsChecked());
	updater->ShouldPackFnNames(itsPackFnMenuCB->IsChecked());

	JXTEBase::SetPartialWordModifier(
		(JXTEBase::PartialWordModifier) itsPWModRG->GetSelectedItem());

	JXTEBase::ShouldUseWindowsHomeEnd(itsHomeEndCB->IsChecked());
	CBTextEditor::CaretShouldFollowScroll(itsScrollCaretCB->IsChecked());
	JTextEditor::ShouldCopyWhenSelect(itsCopyWhenSelectCB->IsChecked());
	JXTEBase::MiddleButtonShouldPaste(itsMiddleButtonPasteCB->IsChecked());

	CBSearchTextDialog* dlog = CBGetSearchTextDialog();
	dlog->SetFont(fontName, fontSize);

	itsDoc->JPrefObject::WritePrefs();

	if (itsEmulatorIndex != itsOrigEmulatorIndex)
		{
		prefsMgr->SetEmulator(kMenuIndexToEmulator[ itsEmulatorIndex-1 ]);
		}

	CBMWriteSharedPrefs(kJTrue);

	pg->ProcessFinished();
	jdelete pg;
}