Index: src/org/openide/explorer/propertysheet/IndexedEditorPanel.java =================================================================== RCS file: /cvs/openide/src/org/openide/explorer/propertysheet/IndexedEditorPanel.java,v retrieving revision 1.11 diff -u -r1.11 IndexedEditorPanel.java --- src/org/openide/explorer/propertysheet/IndexedEditorPanel.java 13 Aug 2003 14:54:45 -0000 1.11 +++ src/org/openide/explorer/propertysheet/IndexedEditorPanel.java 20 Aug 2003 14:06:16 -0000 @@ -21,22 +21,24 @@ import javax.swing.JPanel; import org.openide.explorer.ExplorerManager; -import org.openide.explorer.ExplorerPanel; import org.openide.explorer.view.TreeTableView; import org.openide.nodes.Node; +import org.openide.util.Lookup; import org.openide.util.actions.NodeAction; import org.openide.util.actions.SystemAction; import org.openide.util.NbBundle; -import org.openide.windows.TopComponent; /** * Panel displaying indexed properties. * @author dstrupl@netbeans.org */ -class IndexedEditorPanel extends javax.swing.JPanel implements ExplorerManager.Provider, PropertyChangeListener { +class IndexedEditorPanel extends javax.swing.JPanel +implements ExplorerManager.Provider, PropertyChangeListener, Lookup.Provider { private ExplorerManager em; + /** lookup for move up and down actions */ + private Lookup selectedLookup; private Action moveUp; private Action moveDown; private Action newAction; @@ -53,10 +55,8 @@ treeTableView1 = new TreeTableView(); initComponents(); - ExplorerPanel exPanel = new ExplorerPanel(getExplorerManager()); - exPanel.add(treeTableView1); jPanel2.setLayout(new java.awt.BorderLayout()); - jPanel2.add(exPanel); + jPanel2.add(treeTableView1); detailsPanel.setLayout(new java.awt.BorderLayout()); getExplorerManager().setRootContext(node); @@ -71,13 +71,15 @@ node.addPropertyChangeListener(this); try { + selectedLookup = org.openide.util.lookup.Lookups.proxy (this); + NodeAction globalMoveUp = (NodeAction)SystemAction.get(Class.forName("org.openide.actions.MoveUpAction")); // NOI18N NodeAction globalMoveDown = (NodeAction)SystemAction.get(Class.forName("org.openide.actions.MoveDownAction")); // NOI18N NodeAction globalNewAction = (NodeAction)SystemAction.get(Class.forName("org.openide.actions.NewAction")); // NOI18N // Get context aware instances. - moveUp = globalMoveUp.createContextAwareInstance(exPanel.getLookup()); - moveDown = globalMoveDown.createContextAwareInstance(exPanel.getLookup()); - newAction = globalNewAction.createContextAwareInstance(exPanel.getLookup()); + moveUp = globalMoveUp.createContextAwareInstance(selectedLookup); + moveDown = globalMoveDown.createContextAwareInstance(selectedLookup); + newAction = globalNewAction.createContextAwareInstance(selectedLookup); } catch (ClassNotFoundException cnfe) { } @@ -100,6 +102,13 @@ super.addNotify(); updateButtonState(); } + + /** Returns the lookup of currently selected node. + */ + public Lookup getLookup () { + Node[] arr = getExplorerManager ().getSelectedNodes (); + return arr.length == 1 ? arr[0].getLookup () : Lookup.EMPTY; + } /** This method is called from within the constructor to * initialize the form. @@ -285,6 +294,9 @@ private TreeTableView treeTableView1; private void updateButtonState() { + // refresh the lookup + selectedLookup.lookup (Object.class); + if (showingDetails) { detailsButton.setText(NbBundle.getBundle(IndexedEditorPanel.class).getString("CTL_HideDetails")); } else { @@ -389,10 +401,28 @@ private boolean isEditorScrollable(PropertyPanel p) { Component[] comps = p.getComponents(); for (int i=0; i< comps.length; i++) { - if ( comps[i] instanceof Scrollable || comps[i] instanceof TopComponent ) + if ( comps[i] instanceof Scrollable || isInstanceOfTopComponent (comps[i])) return true; } return false; } + + /** Checks whether an object is instanceof TopComponent + * @param obj the object + * @return true or false + */ + private static boolean isInstanceOfTopComponent (Object obj) { + ClassLoader l = (ClassLoader)org.openide.util.Lookup.getDefault().lookup (ClassLoader.class); + if (l == null) { + l = IndexedEditorPanel.class.getClassLoader(); + } + try { + Class c = Class.forName ("org.openide.windows.TopComponent", true, l); // NOI18N + return c.isInstance(obj); + } catch (Exception ex) { + return false; + } + } + }