bool IssuesWidget::OnEvent(const TBWidgetEvent &ev) { if (!ev.target) return false; TBID id = ev.target->GetID(); if (ev.type == EVENT_TYPE_CLICK) { // we clicked the folder list if (ev.target->GetID() == TBID("issuelist")) { AEJavascript* aejs = GetSubsystem<AEJavascript>(); const Vector<JSError>& errors = aejs->GetJSErrors(); TBSelectList* list = (TBSelectList*) ev.target; TBID tbid = list->GetSelectedItemID(); if (tbid < errors.Size()) { const JSError& error = errors[tbid]; // make sure we are editing it ResourceFrame* rframe = GetSubsystem<MainFrame>()->GetResourceFrame(); rframe->EditResource(error.fullpath); rframe->NavigateToResource(error.fullpath, -1, error.tokenPos); } } } return false; }
void ResourceOps::HandleCreateModule(const String& resourcePath, const String& resourceName, bool navigateToResource, bool reportError) { Editor* editor = GetSubsystem<Editor>(); if (!CheckCreateModule(resourcePath, resourceName, reportError)) return; ResourceCache* cache = GetSubsystem<ResourceCache>(); SharedPtr<File> srcFile = cache->GetFile("ClockworkEditor/templates/template_module.js"); if (srcFile.Null() || !srcFile->IsOpen()) { editor->PostModalError("Create Script Error", "Could not open module template"); return; } String fullpath = resourcePath + resourceName; if (!resourceName.EndsWith(".js")) fullpath += ".js"; if (!CopyFile(srcFile, fullpath)) { String errorMsg; errorMsg.AppendWithFormat("Error copying template:\n\n%s\n\nto:\n\n%s", "ClockworkEditor/template_module.js", fullpath.CString()); editor->PostModalError("Create Module Error", errorMsg); return; } if (navigateToResource) { ResourceFrame* rframe = GetSubsystem<MainFrame>()->GetResourceFrame(); rframe->EditResource(fullpath); } GetSubsystem<MainFrame>()->GetProjectFrame()->Refresh(); }