Index: core/src/org/netbeans/core/windows/RegistryImpl.java =================================================================== RCS file: /cvs/core/src/org/netbeans/core/windows/RegistryImpl.java,v retrieving revision 1.21 diff -u -r1.21 RegistryImpl.java --- core/src/org/netbeans/core/windows/RegistryImpl.java 27 Jul 2001 13:17:08 -0000 1.21 +++ core/src/org/netbeans/core/windows/RegistryImpl.java 6 Dec 2001 17:58:28 -0000 @@ -15,6 +15,8 @@ import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.Set; import java.util.HashSet; import java.util.Arrays; @@ -23,12 +25,13 @@ import javax.swing.SwingUtilities; import javax.swing.MenuElement; +import org.openide.ErrorManager; import org.openide.TopManager; +import org.openide.explorer.*; import org.openide.windows.TopComponent; import org.openide.windows.Workspace; import org.openide.nodes.Node; import org.openide.util.WeakSet; -import org.openide.explorer.ExplorerManager; import org.netbeans.core.NbTopManager; @@ -62,6 +65,25 @@ /** the currently ruling explorer manager */ private ExplorerManager currentManager; + // #18137 hack: + private static final Method explorerActionsGetAttachedManager = findMethod(ExplorerActions.class, "getAttachedManager"); // NOI18N + private static final Method explorerPanelGetActions = findMethod(ExplorerPanel.class, "getActions"); // NOI18N + private static Method findMethod(Class c, String n) { + try { + Method m = c.getDeclaredMethod(n, new Class[0]); + m.setAccessible(true); + return m; + } catch (ThreadDeath td) { + throw td; + } catch (Throwable t) { + notifyQuiet(t); + return null; + } + } + private static void notifyQuiet(Throwable t) { + TopManager.getDefault().getErrorManager().notify(ErrorManager.INFORMATIONAL, t); + } + /** Creates new RegistryImpl */ public RegistryImpl () { support = new PropertyChangeSupport(this); @@ -143,6 +165,25 @@ support.firePropertyChange(PROP_CURRENT_NODES, null, em.getSelectedNodes()); support.firePropertyChange(PROP_ACTIVATED_NODES, null, em.getSelectedNodes()); } + + // #18137: Delete etc. must be updated acc. to this manager + ExplorerActions actions = null; + ExplorerManager actionsPrevious = null; + boolean reflectionOK = false; + try { + actions = (ExplorerActions)explorerPanelGetActions.invoke(null, new Object[0]); + actionsPrevious = (ExplorerManager)explorerActionsGetAttachedManager.invoke(actions, new Object[0]); + reflectionOK = true; + } catch (IllegalAccessException iae) { + notifyQuiet(iae); + } catch (IllegalArgumentException iae) { + notifyQuiet(iae); + } catch (InvocationTargetException ite) { + notifyQuiet(ite); + } + if (reflectionOK) { + actions.attach(em); + } try { @@ -160,6 +201,9 @@ support.firePropertyChange(PROP_ACTIVATED_NODES, null, previous.getSelectedNodes()); } } + if (reflectionOK) { + actions.attach(actionsPrevious); + } } } Index: openide/src/org/openide/explorer/ExplorerActions.java =================================================================== RCS file: /cvs/openide/src/org/openide/explorer/ExplorerActions.java,v retrieving revision 1.42 diff -u -r1.42 ExplorerActions.java --- openide/src/org/openide/explorer/ExplorerActions.java 19 Nov 2001 10:03:35 -0000 1.42 +++ openide/src/org/openide/explorer/ExplorerActions.java 6 Dec 2001 17:58:28 -0000 @@ -105,6 +105,14 @@ manager = null; } + + /** Access method for use from ExplorerPanel, and also + * via reflection (!) from RegistryImpl in core. + * @deprecated Kill me later; see #18137 for explanation. + */ + ExplorerManager getAttachedManager() { + return manager; + } /** Set whether to confirm deletions. * @param yes true to confirm deletions Index: openide/src/org/openide/explorer/ExplorerPanel.java =================================================================== RCS file: /cvs/openide/src/org/openide/explorer/ExplorerPanel.java,v retrieving revision 1.30.4.1 diff -u -r1.30.4.1 ExplorerPanel.java --- openide/src/org/openide/explorer/ExplorerPanel.java 3 Dec 2001 16:00:48 -0000 1.30.4.1 +++ openide/src/org/openide/explorer/ExplorerPanel.java 6 Dec 2001 17:58:28 -0000 @@ -51,7 +51,14 @@ transient private PropertyChangeListener managerListener; /** action handler for cut/copy/paste/delete */ - private static ExplorerActions actions = new ExplorerActions (); + private static final ExplorerActions actions = new ExplorerActions (); + + /** Access method to be used via reflection (!) from core RegistryImpl. + * @deprecated Should be killed later, see #18137. + */ + static ExplorerActions getActions() { + return actions; + } /** Initialize the explorer panel with the provided manager. * @param explorer the explorer manager to use @@ -121,7 +128,9 @@ /* Deactivates copy/cut/paste actions. */ protected void componentDeactivated () { - actions.detach (); + if (getExplorerManager() == actions.getAttachedManager()) { // #18137 + actions.detach (); + } } /** Called when the explored context changes.