void Master::onStart() { CliArguments &args = CliArguments::getInstance(); #ifdef WIN32 m_settings = new Settings("mbedsys.org", "NodeBus", QSettings::NativeFormat); #else m_settings = new Settings(args.getValue("config").toString(), QSettings::NativeFormat); #endif m_settings->define("master/pidfile", tr("Path of the file where the service PID will be written in"), NODEBUS_DEFAULT_PIDFILE); m_settings->define("master/bundle-rootpath", tr("Bundle root directory path"), NODEBUS_DEFAULT_PLUGIN_DIR_PATH); m_settings->define("master/registry-service-name", tr("Registry service name"), NODEBUS_DEFAULT_REGISTRY_SERVICE_NAME); if (args.isEnabled("edit-settings")) { m_settings->setup(); throw ExitApplicationException(); } QString path = m_settings->value("master/bundle-rootpath").toString(); QDirIterator it(path, QStringList("*.so"), QDir::Files, QDirIterator::Subdirectories); logFiner() << "Search for bundles in the directory " << path; while (it.hasNext()) { QString file = it.next(); logFinest() << "Found file " << file; try { BundlePtr bundle = new Bundle(file); m_bundles[bundle->property("Bundle-SymbolicName").toString()] = bundle; logFine() << "Found bundle " << bundle->property("Bundle-Name") << " (" << bundle->property("Bundle-SymbolicName") << ')'; } catch (Exception &e) { logWarn() << "Invalid bundle file " << file << " (" << e.message() << ')'; } } if (m_bundles.isEmpty()) { throw ApplicationException("No valid bundle found in the directory " + path); } }
ExternalTool ExternalTool::fromString(const QString& str) { QStringList outer = str.split(EXTERNAL_TOOL_SEPARATOR); if (outer.size() != 2) { throw ApplicationException(QObject::tr("Passed external tool representation is not valid.")); } else { const QString& executable = outer.at(0); const QStringList parameters = outer.at(1).split(EXTERNAL_TOOL_PARAM_SEPARATOR); return ExternalTool(executable, parameters); } }
/// <summary>Display the currently selected string</summary> void LanguageEditView::OnStringSelectionChanged() { try { // Display new string RichEdit.Refresh(); } catch (ExceptionBase& e) { GetDocument()->SelectedString = nullptr; theApp.ShowError(HERE, ApplicationException(e), L"Unable to display selected string"); } #ifdef RESCINDED // I don't remember why I needed this catch (exception& e) { GetDocument()->SelectedString = nullptr; theApp.ShowError(HERE, e, L"Unable to display selected string"); } #endif }
/// <summary>Opens a new document using a template file.</summary> /// <param name="docPath">Initial document path.</param> /// <param name="t">template.</param> /// <param name="bMakeVisible">make visible.</param> /// <returns></returns> /// <exception cref="Logic::ApplicationException">Unable to create document or view<exception> /// <exception cref="Logic::FileNotFoundException">Template file is missing<exception> DocumentBase* ProjectDocTemplate::OpenDocumentTemplate(Path docPath, const TemplateFile& t, BOOL bMakeVisible) { AppPath templatePath(t.SubPath); ProjectDocument* pDocument = nullptr; // Verify template file exists if (!templatePath.Exists()) throw FileNotFoundException(HERE, templatePath); // Existing document - close/save if (pDocument = dynamic_cast<ProjectDocument*>(m_pOnlyDoc)) if (!pDocument->CloseModified()) return nullptr; // create new doc pDocument = dynamic_cast<ProjectDocument*>(CreateNewDocument()); // Sets m_pOnlyDoc if (!pDocument) throw ApplicationException(HERE, L"Failed to create document class"); // Use default title //SetDefaultTitle(pDocument); // Open template file if (!pDocument->OnOpenTemplate(docPath, t)) { // Failed: Cleanup delete pDocument; return nullptr; } // Set user-selected path (+ update title) pDocument->SetPathName(docPath.c_str(), FALSE); // Raise 'After New Document' pDocument->OnDocumentEvent(CDocument::onAfterNewDocument); // Ensure *MODIFIED* because file doesn't exist on disc yet pDocument->SetModifiedFlag(TRUE); return pDocument; }
/// <summary>Perform text formatting command.</summary> /// <param name="nID">The command identifier.</param> void LanguageEditView::OnPerformCommand(UINT nID) { static int LastButtonID = 1; try { // Execute switch (nID) { // Clipboard: Set based on selection case ID_EDIT_CUT: RichEdit.Cut(); break; case ID_EDIT_COPY: RichEdit.Copy(); break; case ID_EDIT_PASTE: RichEdit.PasteFormat(CF_UNICODETEXT); break; case ID_EDIT_CLEAR: RichEdit.ReplaceSel(L"", TRUE); break; case ID_EDIT_SELECT_ALL: RichEdit.SetSel(0, -1); break; // Undo/Redo: case ID_EDIT_UNDO: RichEdit.Undo(); break; case ID_EDIT_REDO: RichEdit.Redo(); break; // Button: Insert at caret case ID_EDIT_ADD_BUTTON: RichEdit.InsertButton(VString(L"Button %d", LastButtonID++), L"id"); break; // Format: Toggle formatting case ID_EDIT_BOLD: RichEdit.ToggleFormatting(CFE_BOLD); break; case ID_EDIT_ITALIC: RichEdit.ToggleFormatting(CFE_ITALIC); break; case ID_EDIT_UNDERLINE: RichEdit.ToggleFormatting(CFE_UNDERLINE); break; // Alignment: Set alignment case ID_EDIT_LEFT: RichEdit.SetParaFormat(ParaFormat(PFM_ALIGNMENT, Alignment::Left)); break; case ID_EDIT_RIGHT: RichEdit.SetParaFormat(ParaFormat(PFM_ALIGNMENT, Alignment::Right)); break; case ID_EDIT_CENTRE: RichEdit.SetParaFormat(ParaFormat(PFM_ALIGNMENT, Alignment::Centre)); break; case ID_EDIT_JUSTIFY: RichEdit.SetParaFormat(ParaFormat(PFM_ALIGNMENT, Alignment::Justify)); break; // Mode: Attempt Change mode (May fail if syntax errors) case ID_VIEW_SOURCE: GetDocument()->CurrentMode = EditMode::Source; break; case ID_VIEW_EDITOR: GetDocument()->CurrentMode = EditMode::Edit; break; case ID_VIEW_DISPLAY: GetDocument()->CurrentMode = EditMode::Display; break; } // Modify document switch (nID) { // Clipboard: case ID_EDIT_CUT: case ID_EDIT_PASTE: case ID_EDIT_CLEAR: case ID_EDIT_UNDO: case ID_EDIT_REDO: // Format: case ID_EDIT_ADD_BUTTON: case ID_EDIT_COLOUR: case ID_EDIT_BOLD: case ID_EDIT_ITALIC: case ID_EDIT_UNDERLINE: // Alignment: case ID_EDIT_LEFT: case ID_EDIT_RIGHT: case ID_EDIT_CENTRE: case ID_EDIT_JUSTIFY: GetDocument()->SetModifiedFlag(TRUE); break; } } catch (ExceptionBase& e) { theApp.ShowError(HERE, ApplicationException(e)); } }