diff options
Diffstat (limited to 'bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/internal/context/ActiveChildValue.java')
-rw-r--r-- | bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/internal/context/ActiveChildValue.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/internal/context/ActiveChildValue.java b/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/internal/context/ActiveChildValue.java new file mode 100644 index 000000000..89d49f3b5 --- /dev/null +++ b/bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/services/internal/context/ActiveChildValue.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.e4.core.services.internal.context; + +import org.eclipse.e4.core.services.context.IEclipseContext; +import org.eclipse.e4.core.services.context.spi.IComputedValue; + +/** + * A computed value that delegates lookup to a child context. + * TODO: There might be different bundles with their own notion of "active child", + * so to make this more reusable the "activeChild" constant should likely be pulled + * out and live in the UI ("activeChildControl" or some such), allowing others to store + * their own notion of child under a different key. + */ +public final class ActiveChildValue implements IComputedValue { + private final String attr; + + public ActiveChildValue(String attr) { + this.attr = attr; + } + + public Object compute(IEclipseContext context, String[] arguments) { + if (context.isSet("activeChild")) { + IEclipseContext childContext = (IEclipseContext) context.get("activeChild"); + return childContext.get(attr); + } + return null; + } +}
\ No newline at end of file |