Viewing Custom Tool Usage

This tool allows you to view usage logs for your custom tools. The usage logs are created in configuration files by the Record Usage functionality. See

//  Custom Tool Usage Viewer

/*
	Custom Tool Usage Viewer

	Presents a list of Custom Tools and their usage logs.

	03-APR-2012 		Tony Goodman		Initial version. Adapted from ConfEditor.

*/

DB  dbMain = null
DBE dbeToolNames = null
DBE dbeFileContents = null
DBE dbeSplitter = null

Buffer b = create
ConfStream st = null

string CONF_DIR = "tool_usage"

string dummy[] = {}

/***********************
	initialiseToolNames
***********************/
void initialiseToolNames()
{
	int i  = 0
	string s = ""

	insertColumn(dbeToolNames, 0, "Custom Tools", 240, iconNone)

	for s in confDirectory(CONF_DIR, confSystem) do
	{
		if (s == "." || s == "..") continue

		insert(dbeToolNames, i, s)
	}
}

/***********************
	doSelect
***********************/
void doSelect(DBE dbe, int i)
{
	string toolName = get(dbeToolNames)

	setempty(b)

	st = confRead(CONF_DIR "\\" toolName, confSystem)

	if (!null st)
	{
		while (true)
		{
			st >> s

			if (end st) break

			b += s "\n"
		}

		close(st)
	}

	set(dbeFileContents, stringOf(b))
}

/***********************
	doActivate
***********************/
void doActivate(DBE dbe, int i)
{
	doSelect(dbe, i)
}

/***********************
	doDeselect
***********************/
void doDeselect(DBE dbe, int i)
{
	;
}

/***********************
	createDialog
***********************/
void createDialog()
{
	dbMain = create(dbExplorer, "Tool Usage Viewer")

	dbeToolNames = listView(dbMain, 0, 250, 10, dummy)
	dbeToolNames->"right"->"unattached"
	dbeToolNames->"bottom"->"form"
	dbeToolNames->"left"->"form"

	dbeFileContents = text(dbMain, "", "", 800, 400, false)
	dbeFileContents->"left"->"unattached"
	dbeFileContents->"top"->"aligned"->dbeToolNames
	dbeFileContents->"bottom"->"form"
	dbeFileContents->"right"->"form"

	dbeSplitter = splitter(dbMain, dbeToolNames, dbeFileContents, 5)
	dbeSplitter->"top"->"aligned"->dbeToolNames
	dbeSplitter->"bottom"->"form"
	dbeSplitter->"left"->"unattached"
	dbeSplitter->"right"->"unattached"

	realize(dbMain)

	set(dbeToolNames, doSelect, doDeselect, doActivate)

	initialiseToolNames()

	show(dbMain)
}

/***********************
	MAIN
***********************/
createDialog()