SmartPointer<const IStatus> EditorHistoryItem::SaveState(const SmartPointer<IMemento>& memento) { if (!IsRestored()) { memento->PutMemento(this->memento); } else if (input.IsNotNull()) { const IPersistableElement* persistable = input->GetPersistable(); if (persistable != nullptr) { /* * Store IPersistable of the IEditorInput in a separate section * since it could potentially use a tag already used in the parent * memento and thus overwrite data. */ IMemento::Pointer persistableMemento = memento->CreateChild(WorkbenchConstants::TAG_PERSISTABLE); persistable->SaveState(persistableMemento); memento->PutString(WorkbenchConstants::TAG_FACTORY_ID, persistable->GetFactoryId()); if (descriptor.IsNotNull() && !descriptor->GetId().isEmpty()) { memento->PutString(WorkbenchConstants::TAG_ID, descriptor->GetId()); } // save the name and tooltip separately so they can be restored // without having to instantiate the input, which can activate plugins memento->PutString(WorkbenchConstants::TAG_NAME, input->GetName()); memento->PutString(WorkbenchConstants::TAG_TOOLTIP, input->GetToolTipText()); } } return Status::OK_STATUS(BERRY_STATUS_LOC); }
SmartPointer<const IStatus> EditorHistory::SaveState(const SmartPointer<IMemento>& memento) const { for (auto iter = fifoList.begin(); iter != fifoList.end(); ++iter) { if ((*iter)->CanSave()) { IMemento::Pointer itemMemento = memento->CreateChild(WorkbenchConstants::TAG_FILE); (*iter)->SaveState(itemMemento); } } return Status::OK_STATUS(BERRY_STATUS_LOC); }