Exemple #1
0
void ItemPageUI::OnItemSelect()
{
	string compName = m_itemComboBox->GetSelectedText();
	int id = reinterpret_cast<int>(HashedString::hash_name(compName.c_str()));
	Item selectedItem;
	if (!m_itemList->GetItemByID(id, selectedItem))
		return;
	GenerateForm(selectedItem);
}
void ComponentPageUI::OnComponentComboSelect()
{
	string compName = m_componentComboBox->GetSelectedText();
	int id = reinterpret_cast<int>(HashedString::hash_name(compName.c_str()));
	Component selectedComp;
	if (!m_componentList->GetComponentByID(id, selectedComp))
		return;
	GenerateForm(selectedComp);
	m_saveComponentBtn->Show(true);
	m_clearForm = true;
	m_updateForm = true;
}
int
main
	(
	int		argc,
	char*	argv[]
	)
{
	// find the configuration files

	if (!FindConfigFile(&classMapFile) ||
		!FindConfigFile(&optionMapFile) ||
		!FindConfigFile(&needFontListFile) ||
		!FindConfigFile(&needStringListFile) ||
		!FindConfigFile(&needCreateListFile))
		{
		return 1;
		}

	// parse the command line options

	JString inputName, codePath, stringPath, codeSuffix, headerSuffix;
	JString postCmd;
	JPtrArray<JString> userFormList(JPtrArrayT::kDeleteAll);	// empty => generate all forms
	JPtrArray<JString> backupList(JPtrArrayT::kDeleteAll);		// forms that have been backed up
	GetOptions(argc, argv, &inputName, &codePath, &stringPath,
			   &codeSuffix, &headerSuffix, &postCmd, &userFormList);

	// generate each requested form

	JBoolean changed = kJFalse;

	ifstream input(inputName);
	while (!input.eof() && !input.fail())
		{
		const JString line = JReadLine(input);
		if (line == kBeginFormLine)
			{
			// get form name

			JString formName = JReadLine(input);
			RemoveIdentifier(kFormNameMarker, &formName);

			// look for custom tag

			const JSize formNameLength = formName.GetLength();
			JString tagName            = kDefaultDelimTag;
			JString enclName;
			JIndex tagMarkerIndex;
			if (formName.LocateSubstring(kCustomTagMarker, &tagMarkerIndex) &&
				tagMarkerIndex <= formNameLength - kCustomTagMarkerLength)
				{
				tagName = formName.GetSubstring(
					tagMarkerIndex + kCustomTagMarkerLength, formNameLength);
				formName.RemoveSubstring(tagMarkerIndex, formNameLength);

				// get enclosure name

				const JSize tagNameLength = tagName.GetLength();
				JIndex enclMarkerIndex;
				if (tagName.LocateSubstring(kCustomTagMarker, &enclMarkerIndex) &&
					enclMarkerIndex <= tagNameLength - kCustomTagMarkerLength)
					{
					enclName = tagName.GetSubstring(
						enclMarkerIndex + kCustomTagMarkerLength, tagNameLength);
					tagName.RemoveSubstring(enclMarkerIndex, tagNameLength);
					}

				// report errors

				if (tagName != kDefaultDelimTag)
					{
					if (enclName.IsEmpty())
						{
						cerr << formName << ", " << tagName;
						cerr << ": no enclosure specified" << endl;
						}
					}
				else if (!enclName.IsEmpty() && enclName != kDefTopEnclVarName)
					{
					cerr << formName << ", " << tagName;
					cerr << ": not allowed to specify enclosure other than ";
					cerr << kDefTopEnclVarName << endl;
					}
				}

			if (ShouldGenerateForm(formName, userFormList))
				{
				GenerateForm(input, formName, tagName, enclName,
							 codePath, stringPath, codeSuffix, headerSuffix, &backupList);
				changed = kJTrue;
				}
			}
		}

	if (changed && !postCmd.IsEmpty())
		{
		const JError err = JExecute(postCmd, NULL);
		err.ReportIfError();
		}

	return 0;
}
void ComponentPageUI::OnAddNewComponent()
{
	Component component;
	GenerateForm(component);
	m_saveComponentBtn->Show(true);
}
Exemple #5
0
void ItemPageUI::OnCreateNewItem()
{
	Item item;
	GenerateForm(item);
}