コード例 #1
0
ファイル: berryViewFactory.cpp プロジェクト: 151706061/MITK
//  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;
}
コード例 #2
0
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));
  }
}
コード例 #3
0
void DetachedPlaceHolder::SaveState(IMemento::Pointer memento)
{
  // Save the bounds.
  memento->PutInteger(WorkbenchConstants::TAG_X, bounds.x);
  memento->PutInteger(WorkbenchConstants::TAG_Y, bounds.y);
  memento->PutInteger(WorkbenchConstants::TAG_WIDTH, bounds.width);
  memento->PutInteger(WorkbenchConstants::TAG_HEIGHT, bounds.height);

  // Save the views.
  for (std::list<LayoutPart::Pointer>::iterator i = children.begin();
      i != children.end(); ++i) {
     IMemento::Pointer childMem = memento
             ->CreateChild(WorkbenchConstants::TAG_VIEW);
     childMem->PutString(WorkbenchConstants::TAG_ID, (*i)->GetID());
  }
}