bool CMIRIAMInfo::save() { CCopasiObject * pCopasiObject = dynamic_cast< CCopasiObject * >(CCopasiRootContainer::getKeyFactory()->get(mKey)); if (pCopasiObject && mpRDFGraph) { mpRDFGraph->clean(); mpRDFGraph->updateNamespaces(); std::string XML = CRDFWriter::xmlFromGraph(mpRDFGraph); CAnnotation * pAnnotation = CAnnotation::castObject(pCopasiObject); if (pAnnotation == NULL) { return false; } pAnnotation->setMiriamAnnotation(XML, pAnnotation->getKey(), pAnnotation->getKey()); return true; } return false; }
bool AnnotateDialog::SetNewLineFoundIfMatches(unsigned int index, const std::string& searchString, bool caseSensitive) { CAnnotation* annotation = (*myAnnotations)[index]; if (annotation->IsTextMatching(searchString, caseSensitive)) { if (index != myFoundLineIndex) { if (myFoundLineIndex != std::numeric_limits<unsigned int>::max()) { *((wxColour*)(*myAnnotations)[myFoundLineIndex]->Data()) = myFoundLinePreviousColour; myListCtrl->RefreshItem(myFoundLineIndex); } myFoundLinePreviousColour = *((wxColour*)annotation->Data()); myFoundLineIndex = index; *((wxColour*)annotation->Data()) = wxColour(ANNOTATE_HIGHLIGHT_FIND_RGB); } myAnnotateCanvas->RefreshLineColors(myAnnotations, myAnnotations->AnnotationCount(), myListCtrl->GetCountPerPage(), myHighlightType); myListCtrl->EnsureVisible(myFoundLineIndex); myListCtrl->RefreshItem(myFoundLineIndex); return true; } return false; }
void AnnotateDialog::ListItemClick(wxListEvent& event) { if (myShowLogMessages) { CAnnotation* annotation = (*myAnnotations)[event.GetIndex()]; myStatusBar->SetStatusText(wxText(annotation->LogMessage()), 1); } }
void CQNotes::save() { if (mpObject != NULL && mValidity == QValidator::Acceptable) { QString Notes; CAnnotation * pAnnotation = CAnnotation::castObject(mpObject); CReportDefinition * pReportDefinition = static_cast< CReportDefinition * >(mpObject); if (pAnnotation != NULL) { Notes = FROM_UTF8(pAnnotation->getNotes()); } else if (pReportDefinition != NULL) { Notes = FROM_UTF8(pReportDefinition->getComment()); } if (mpEdit->toPlainText() != Notes) { std::string PlainText = TO_UTF8(mpEdit->toPlainText()); if (mpValidatorXML->needsWrap()) { // We wrap the HTML in a body element if it does not contain a top level html or body element. PlainText = "<body xmlns=\"http://www.w3.org/1999/xhtml\">" + PlainText + "</body>"; } if (pAnnotation != NULL) { pAnnotation->setNotes(PlainText); } else if (pReportDefinition != NULL) { pReportDefinition->setComment(PlainText); } mChanged = true; } } if (mChanged) { if (mpDataModel != NULL) { mpDataModel->changed(); } protectedNotify(ListViews::MODEL, ListViews::CHANGE, mKey); mChanged = false; } return; }
void CMIRIAMInfo::load(const std::string& key) { pdelete(mpRDFGraph); mKey = key; CCopasiObject * pCopasiObject = dynamic_cast< CCopasiObject * >(CCopasiRootContainer::getKeyFactory()->get(mKey)); if (pCopasiObject != NULL) { const std::string * pMiriamAnnotation = NULL; CAnnotation * pAnnotation = CAnnotation::castObject(pCopasiObject); if (pAnnotation != NULL) { pMiriamAnnotation = &pAnnotation->getMiriamAnnotation(); } if (pMiriamAnnotation && *pMiriamAnnotation != "") mpRDFGraph = CRDFParser::graphFromXml(*pMiriamAnnotation); } if (mpRDFGraph == NULL) mpRDFGraph = new CRDFGraph; // We make sure that we always have an about node. if (pCopasiObject != NULL) mTriplet.pObject = mpRDFGraph->createAboutNode(pCopasiObject->getKey()); else mTriplet.pObject = mpRDFGraph->createAboutNode(""); // Load the created date if set; CRDFPredicate::Path Path = mTriplet.pObject->getPath(); std::set< CRDFTriplet > Triples = mTriplet.pObject->getDescendantsWithPredicate(CRDFPredicate::dcterms_created); if (Triples.size() > 0) mCreated = *Triples.begin(); else mCreated = CRDFTriplet(); // This is an invalid triplet, i.e., !mCreated is true. loadCreators(); loadReferences(); loadModifications(); loadBiologicalDescriptions(); return; }
void AnnotateDialog::Populate(CAnnotationList* annotationList) { TDEBUG_ENTER("AnnotateDialog::Populate"); myAnnotations = annotationList; unsigned int annotateCount = annotationList->AnnotationCount(); myListCtrl->SetItemCount(annotateCount); // Create the line color array delete[] myLineColors; myLineColors = new wxColour[annotateCount]; for (unsigned int i = 0; i < annotateCount; i++) { CAnnotation* item = (*annotationList)[i]; TDEBUG_TRACE("Item " << i << ": " << asctime(&(item->Date())) << item->Text()); item->SetData(&myLineColors[i]); } ApplySort(); }
void CQNotes::load() { if (mpObject != NULL) { QString Notes; CAnnotation * pAnnotation = CAnnotation::castObject(mpObject); CReportDefinition * pReportDefinition = static_cast< CReportDefinition * >(mpObject); if (pAnnotation != NULL) { Notes = FROM_UTF8(pAnnotation->getNotes()); } else if (pReportDefinition != NULL) { Notes = FROM_UTF8(pReportDefinition->getComment()); } // The notes are UTF8 encoded however the html does not specify an encoding // thus Qt uses locale settings. mpWebView->setHtml(Notes); mpEdit->setPlainText(Notes); mpValidatorXML->saved(); slotValidateXML(); if (!mpValidatorXML->isFreeText() && mEditMode) { slotToggleMode(); } mValidity = QValidator::Acceptable; } mChanged = false; return; }
bool CQMiriamWidget::enterProtected() { if (mKey == "") return false; CCopasiMessage::clearDeque(); if (mKeyToCopy != "") { CAnnotation * pAnnotation = CAnnotation::castObject(dynamic_cast< CCopasiObject * >(CCopasiRootContainer::getKeyFactory()->get(mKeyToCopy))); std::string pMiriamAnnotation = pAnnotation->getMiriamAnnotation(); pAnnotation = CAnnotation::castObject(mpObject); pAnnotation->setMiriamAnnotation(pMiriamAnnotation, mKey, mKeyToCopy); mKeyToCopy = ""; } mpMIRIAMInfo->load(mKey); //Set Models for the 4 TableViews std::vector<CQTableView*>::const_iterator it = mWidgets.begin(); std::vector<CQTableView*>::const_iterator end = mWidgets.end(); std::vector<CQBaseDataModel*>::const_iterator itDM = mDMs.begin(); std::vector<CQBaseDataModel*>::const_iterator endDM = mDMs.end(); std::vector<CQSortFilterProxyModel*>::const_iterator itPDM = mProxyDMs.begin(); std::vector<CQSortFilterProxyModel*>::const_iterator endPDM = mProxyDMs.end(); for (; it != end && itDM != endDM && itPDM != endPDM; it++, itDM++, itPDM++) { (*itPDM)->setSourceModel(*itDM); (*it)->setModel(NULL); (*it)->setModel(*itPDM); (*it)->resizeColumnsToContents(); } QDateTime DTCreated; if (mpMIRIAMInfo->getCreatedDT() != "") DTCreated = QDateTime::fromString(FROM_UTF8(mpMIRIAMInfo->getCreatedDT()), Qt::ISODate); if (DTCreated.isValid()) mpDTCreated->setDateTime(DTCreated); else { mpDTCreated->setDateTime(QDateTime::currentDateTime()); } if (CCopasiMessage::size() > 0) { mMessageType = CCopasiMessage::getHighestSeverity(); mMessage = CCopasiMessage::getAllMessageText(); CCopasiMessage::clearDeque(); showEvent(NULL); } else { mMessageType = -1; mMessage = ""; } return true; }