コード例 #1
0
void
TFilePanel::OpenParent()
{
	if (!CanOpenParent())
		return;

	BEntry parentEntry;
	BDirectory dir;

	Model oldModel(*PoseView()->TargetModel());
	BEntry entry(oldModel.EntryRef());

	if (entry.InitCheck() == B_OK
		&& entry.GetParent(&dir) == B_OK
		&& dir.GetEntry(&parentEntry) == B_OK
		&& entry != parentEntry) {

		entry_ref ref;
		parentEntry.GetRef(&ref);

		PoseView()->SetIsDesktop(SwitchDirToDesktopIfNeeded(ref));
		PoseView()->SwitchDir(&ref);
		SwitchDirMenuTo(&ref);

		// make sure the child get's selected in the new view once it
		// shows up
		fTaskLoop->RunLater(NewMemberFunctionObjectWithResult
			(&TFilePanel::SelectChildInParent, this,
			const_cast<const entry_ref*>(&ref),
			oldModel.NodeRef()), 100000, 200000, 5000000);
	}
}
コード例 #2
0
NS_IMETHODIMP
nsXFormsControlStub::BindToModel(PRBool aSetBoundNode)
{
  if (GetRepeatState() == eType_Template) {
    // No sense going any further.  A template control has no need to bind,
    // refresh, etc. so no reason to put it on the model's control list
    return NS_OK;
  }

  nsCOMPtr<nsIModelElementPrivate> oldModel(mModel);

  nsCOMPtr<nsIXFormsControl> parentControl;
  nsCOMPtr<nsIDOMNode> boundNode;
  mModel = nsXFormsUtils::GetModel(mElement, getter_AddRefs(parentControl),
                                   kElementFlags,
                                   getter_AddRefs(boundNode));
  if (aSetBoundNode) {
    mBoundNode.swap(boundNode);
  }

  return MaybeAddToModel(oldModel, parentControl);
}
コード例 #3
0
nsresult
nsXFormsControlStub::ProcessNodeBinding(const nsString          &aBindingAttr,
                                        PRUint16                 aResultType,
                                        nsIDOMXPathResult      **aResult,
                                        nsIModelElementPrivate **aModel)
{
  nsStringArray indexesUsed;

  if (aResult) {
    *aResult = nsnull;
  }

  if (aModel) {
    *aModel = nsnull;
  }

  // let's not go through all of this rigamarol if we don't have a chance
  // in heck of binding anyhow.  Check to see if the models will be receptive
  // to some binding.  readyForBindProperty is set when they are.  Make sure
  // to return NS_OK so that we don't start complaining about binding
  // failures in this situation.

  if (!nsXFormsUtils::IsDocumentReadyForBind(mElement)) {
    nsXFormsModelElement::DeferElementBind(this);
    return NS_OK_XFORMS_DEFERRED;
  }

  nsresult rv;
  PRBool usesModelBinding;
  nsCOMPtr<nsIModelElementPrivate> oldModel(mModel);
  nsCOMPtr<nsIXFormsControl> parentControl;
  rv = nsXFormsUtils::EvaluateNodeBinding(mElement,
                                          kElementFlags,
                                          aBindingAttr,
                                          EmptyString(),
                                          aResultType,
                                          getter_AddRefs(mModel),
                                          aResult,
                                          &usesModelBinding,
                                          getter_AddRefs(parentControl),
                                          &mDependencies,
                                          &indexesUsed);
  NS_ENSURE_SUCCESS(rv, rv);

  // if NS_OK_XFORMS_NOTREADY, mModel probably won't exist or might no longer
  // be valid, so shouldn't continue.
  if (rv == NS_OK_XFORMS_NOTREADY) {
    return rv;
  }

  NS_ENSURE_STATE(mModel);

  rv = MaybeAddToModel(oldModel, parentControl);
  NS_ENSURE_SUCCESS(rv, rv);

  if (aModel)
    NS_ADDREF(*aModel = mModel);

  mUsesModelBinding = usesModelBinding;

  if (indexesUsed.Count()) {
    // add index listeners on repeat elements

    for (PRInt32 i = 0; i < indexesUsed.Count(); ++i) {
      // Find the repeat element and add |this| as a listener
      nsCOMPtr<nsIDOMElement> repElem;
      nsXFormsUtils::GetElementByContextId(mElement, *(indexesUsed[i]),
                                           getter_AddRefs(repElem));
      nsCOMPtr<nsIXFormsRepeatElement> rep(do_QueryInterface(repElem));
      if (!rep)
        continue;

      rv = rep->AddIndexUser(this);
      NS_ENSURE_SUCCESS(rv, rv);

      rv = mIndexesUsed.AppendObject(rep);
      NS_ENSURE_SUCCESS(rv, rv);
    }
  }

  return NS_OK;
}