|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.openide.windows; import org.openide.util.Lookup; import org.openide.util.ContextGlobalProvider; import org.openide.windows.TopComponent; /** An interface that can be registered in a lookup by subsystems * wish to provide a global context actions should react to. * * @author Jaroslav Tulach */ public final class GlobalActionContextImpl extends Object implements ContextGlobalProvider, Lookup.Provider, java.beans.PropertyChangeListener { /** registry to work with */ private TopComponent.Registry registry; public GlobalActionContextImpl () { this (TopComponent.getRegistry()); } public GlobalActionContextImpl (TopComponent.Registry r) { this.registry = r; } /** Let's create the proxy listener that delegates to currently * selected top component. */ public Lookup createGlobalContext() { registry.addPropertyChangeListener(this); return org.openide.util.lookup.Lookups.proxy(this); } /** The current component lookup */ public Lookup getLookup() { TopComponent tc = registry.getActivated(); return tc == null ? Lookup.EMPTY : tc.getLookup(); } /** Requests refresh of our lookup everytime component is chagned. */ public void propertyChange(java.beans.PropertyChangeEvent evt) { if (TopComponent.Registry.PROP_ACTIVATED.equals (evt.getPropertyName())) { org.openide.util.Utilities.actionsGlobalContext ().lookup (javax.swing.ActionMap.class); } } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.