This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 18137
Collapse All | Expand All

(-)core/src/org/netbeans/core/windows/RegistryImpl.java (-1 / +45 lines)
Lines 15-20 Link Here
15
15
16
import java.beans.PropertyChangeListener;
16
import java.beans.PropertyChangeListener;
17
import java.beans.PropertyChangeSupport;
17
import java.beans.PropertyChangeSupport;
18
import java.lang.reflect.InvocationTargetException;
19
import java.lang.reflect.Method;
18
import java.util.Set;
20
import java.util.Set;
19
import java.util.HashSet;
21
import java.util.HashSet;
20
import java.util.Arrays;
22
import java.util.Arrays;
Lines 23-34 Link Here
23
import javax.swing.SwingUtilities;
25
import javax.swing.SwingUtilities;
24
import javax.swing.MenuElement;
26
import javax.swing.MenuElement;
25
27
28
import org.openide.ErrorManager;
26
import org.openide.TopManager;
29
import org.openide.TopManager;
30
import org.openide.explorer.*;
27
import org.openide.windows.TopComponent;
31
import org.openide.windows.TopComponent;
28
import org.openide.windows.Workspace;
32
import org.openide.windows.Workspace;
29
import org.openide.nodes.Node;
33
import org.openide.nodes.Node;
30
import org.openide.util.WeakSet;
34
import org.openide.util.WeakSet;
31
import org.openide.explorer.ExplorerManager;
32
35
33
import org.netbeans.core.NbTopManager;
36
import org.netbeans.core.NbTopManager;
34
37
Lines 62-67 Link Here
62
  /** the currently ruling explorer manager */
65
  /** the currently ruling explorer manager */
63
  private ExplorerManager currentManager;
66
  private ExplorerManager currentManager;
64
  
67
  
68
  // #18137 hack:
69
  private static final Method explorerActionsGetAttachedManager = findMethod(ExplorerActions.class, "getAttachedManager"); // NOI18N
70
  private static final Method explorerPanelGetActions = findMethod(ExplorerPanel.class, "getActions"); // NOI18N
71
  private static Method findMethod(Class c, String n) {
72
      try {
73
          Method m = c.getDeclaredMethod(n, new Class[0]);
74
          m.setAccessible(true);
75
          return m;
76
      } catch (ThreadDeath td) {
77
          throw td;
78
      } catch (Throwable t) {
79
          notifyQuiet(t);
80
          return null;
81
      }
82
  }
83
  private static void notifyQuiet(Throwable t) {
84
      TopManager.getDefault().getErrorManager().notify(ErrorManager.INFORMATIONAL, t);
85
  }
86
  
65
  /** Creates new RegistryImpl */
87
  /** Creates new RegistryImpl */
66
  public RegistryImpl () {
88
  public RegistryImpl () {
67
    support = new PropertyChangeSupport(this);
89
    support = new PropertyChangeSupport(this);
Lines 143-148 Link Here
143
        support.firePropertyChange(PROP_CURRENT_NODES, null, em.getSelectedNodes());
165
        support.firePropertyChange(PROP_CURRENT_NODES, null, em.getSelectedNodes());
144
        support.firePropertyChange(PROP_ACTIVATED_NODES, null, em.getSelectedNodes());
166
        support.firePropertyChange(PROP_ACTIVATED_NODES, null, em.getSelectedNodes());
145
    }
167
    }
168
    
169
    // #18137: Delete etc. must be updated acc. to this manager
170
    ExplorerActions actions = null;
171
    ExplorerManager actionsPrevious = null;
172
    boolean reflectionOK = false;
173
    try {
174
        actions = (ExplorerActions)explorerPanelGetActions.invoke(null, new Object[0]);
175
        actionsPrevious = (ExplorerManager)explorerActionsGetAttachedManager.invoke(actions, new Object[0]);
176
        reflectionOK = true;
177
    } catch (IllegalAccessException iae) {
178
        notifyQuiet(iae);
179
    } catch (IllegalArgumentException iae) {
180
        notifyQuiet(iae);
181
    } catch (InvocationTargetException ite) {
182
        notifyQuiet(ite);
183
    }
184
    if (reflectionOK) {
185
        actions.attach(em);
186
    }
146
187
147
    try {
188
    try {
148
189
Lines 160-165 Link Here
160
            support.firePropertyChange(PROP_ACTIVATED_NODES, null, previous.getSelectedNodes());
201
            support.firePropertyChange(PROP_ACTIVATED_NODES, null, previous.getSelectedNodes());
161
          }
202
          }
162
      }   
203
      }   
204
      if (reflectionOK) {
205
          actions.attach(actionsPrevious);
206
      }
163
    }
207
    }
164
  }
208
  }
165
      
209
      
(-)openide/src/org/openide/explorer/ExplorerActions.java (+8 lines)
Lines 105-110 Link Here
105
105
106
        manager = null;
106
        manager = null;
107
    }
107
    }
108
    
109
    /** Access method for use from ExplorerPanel, and also
110
     * via reflection (!) from RegistryImpl in core.
111
     * @deprecated Kill me later; see #18137 for explanation.
112
     */
113
    ExplorerManager getAttachedManager() {
114
        return manager;
115
    }
108
116
109
    /** Set whether to confirm deletions.
117
    /** Set whether to confirm deletions.
110
    * @param yes <code>true</code> to confirm deletions
118
    * @param yes <code>true</code> to confirm deletions
(-)openide/src/org/openide/explorer/ExplorerPanel.java (-2 / +11 lines)
Lines 51-57 Link Here
51
    transient private PropertyChangeListener managerListener;
51
    transient private PropertyChangeListener managerListener;
52
52
53
    /** action handler for cut/copy/paste/delete */
53
    /** action handler for cut/copy/paste/delete */
54
    private static ExplorerActions actions = new ExplorerActions ();
54
    private static final ExplorerActions actions = new ExplorerActions ();
55
    
56
    /** Access method to be used via reflection (!) from core RegistryImpl.
57
     * @deprecated Should be killed later, see #18137.
58
     */
59
    static ExplorerActions getActions() {
60
        return actions;
61
    }
55
62
56
    /** Initialize the explorer panel with the provided manager.
63
    /** Initialize the explorer panel with the provided manager.
57
    * @param explorer the explorer manager to use
64
    * @param explorer the explorer manager to use
Lines 121-127 Link Here
121
    /* Deactivates copy/cut/paste actions.
128
    /* Deactivates copy/cut/paste actions.
122
    */
129
    */
123
    protected void componentDeactivated () {
130
    protected void componentDeactivated () {
124
        actions.detach ();
131
        if (getExplorerManager() == actions.getAttachedManager()) { // #18137
132
            actions.detach ();
133
        }
125
    }
134
    }
126
135
127
    /** Called when the explored context changes.
136
    /** Called when the explored context changes.

Return to bug 18137