// for dynamic UI IMemento::Pointer ViewFactory::SaveViewState(IMemento::Pointer memento, IViewReference::Pointer ref, bool& res) { //final MultiStatus result = res; bool& result = res; IMemento::Pointer viewMemento = memento->CreateChild( WorkbenchConstants::TAG_VIEW); viewMemento->PutString(WorkbenchConstants::TAG_ID, ViewFactory::GetKey(ref)); if (ViewReference::Pointer viewRef = ref.Cast<ViewReference>()) { viewMemento->PutString(WorkbenchConstants::TAG_PART_NAME, viewRef->GetPartName()); } const IViewReference::Pointer viewRef = ref; const IViewPart::Pointer view = ref->GetPart(false).Cast<IViewPart> (); if (view) { ISafeRunnable::Pointer runnable(new SaveViewRunnable(view, viewMemento, result)); SafeRunner::Run(runnable); } else { IMemento::Pointer mem; IMemento::Pointer props; // if we've created the reference once, any previous workbench // state memento is there. After once, there is no previous // session state, so it should be null. if (ref.Cast<ViewReference> ()) { mem = ref.Cast<ViewReference> ()->GetMemento(); if (mem) { props = mem->GetChild(WorkbenchConstants::TAG_PROPERTIES); mem = mem->GetChild(WorkbenchConstants::TAG_VIEW_STATE); } } if (props) { viewMemento->CreateChild(WorkbenchConstants::TAG_PROPERTIES) ->PutMemento( props); } if (mem) { IMemento::Pointer child = viewMemento ->CreateChild( WorkbenchConstants::TAG_VIEW_STATE); child->PutMemento(mem); } } return viewMemento; }
void LeftToRightTabOrder::SaveState(IPresentationSerializer* context, IMemento::Pointer memento) { std::vector<IPresentablePart::Pointer> parts(list->GetPartList()); for (std::vector<IPresentablePart::Pointer>::iterator iter = parts.begin(); iter != parts.end(); ++iter) { IMemento::Pointer childMem = memento->CreateChild(WorkbenchConstants::TAG_PART); childMem->PutString(WorkbenchConstants::TAG_ID, context->GetId(*iter)); } }
void Run() override { const QHash<QString, QString>& properties = view->GetPartProperties(); if (!properties.empty()) { IMemento::Pointer propBag = viewMemento ->CreateChild( WorkbenchConstants::TAG_PROPERTIES); for (QHash<QString, QString>::const_iterator i = properties.begin(); i != properties.end(); ++i) { IMemento::Pointer p = propBag->CreateChild( WorkbenchConstants::TAG_PROPERTY, i.key()); p->PutTextData(i.value()); } } view->SaveState(viewMemento ->CreateChild( WorkbenchConstants::TAG_VIEW_STATE)); }
void Run() { const std::map<std::string, std::string>& properties = view->GetPartProperties(); if (!properties.empty()) { IMemento::Pointer propBag = viewMemento ->CreateChild( WorkbenchConstants::TAG_PROPERTIES); for (std::map<std::string, std::string>::const_iterator i = properties.begin(); i != properties.end(); ++i) { IMemento::Pointer p = propBag->CreateChild( WorkbenchConstants::TAG_PROPERTY, i->first); p->PutTextData(i->second); } } view->SaveState(viewMemento ->CreateChild( WorkbenchConstants::TAG_VIEW_STATE)); }