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 35334
Collapse All | Expand All

(-)src/org/openide/explorer/propertysheet/IndexedEditorPanel.java (-10 / +40 lines)
Lines 21-42 Link Here
21
import javax.swing.JPanel;
21
import javax.swing.JPanel;
22
                
22
                
23
import org.openide.explorer.ExplorerManager;
23
import org.openide.explorer.ExplorerManager;
24
import org.openide.explorer.ExplorerPanel;
25
import org.openide.explorer.view.TreeTableView;
24
import org.openide.explorer.view.TreeTableView;
26
import org.openide.nodes.Node;
25
import org.openide.nodes.Node;
26
import org.openide.util.Lookup;
27
import org.openide.util.actions.NodeAction;
27
import org.openide.util.actions.NodeAction;
28
import org.openide.util.actions.SystemAction;
28
import org.openide.util.actions.SystemAction;
29
import org.openide.util.NbBundle;
29
import org.openide.util.NbBundle;
30
import org.openide.windows.TopComponent;
31
30
32
/**
31
/**
33
 * Panel displaying indexed properties.
32
 * Panel displaying indexed properties.
34
 * @author  dstrupl@netbeans.org
33
 * @author  dstrupl@netbeans.org
35
 */
34
 */
36
class IndexedEditorPanel extends javax.swing.JPanel implements ExplorerManager.Provider, PropertyChangeListener {
35
class IndexedEditorPanel extends javax.swing.JPanel 
36
implements ExplorerManager.Provider, PropertyChangeListener, Lookup.Provider {
37
37
38
    private ExplorerManager em;
38
    private ExplorerManager em;
39
39
40
    /** lookup for move up and down actions */
41
    private Lookup selectedLookup;
40
    private Action moveUp;
42
    private Action moveUp;
41
    private Action moveDown;
43
    private Action moveDown;
42
    private Action newAction;
44
    private Action newAction;
Lines 53-62 Link Here
53
        treeTableView1 = new TreeTableView();
55
        treeTableView1 = new TreeTableView();
54
        initComponents();
56
        initComponents();
55
        
57
        
56
        ExplorerPanel exPanel = new ExplorerPanel(getExplorerManager());
57
        exPanel.add(treeTableView1);
58
        jPanel2.setLayout(new java.awt.BorderLayout());
58
        jPanel2.setLayout(new java.awt.BorderLayout());
59
        jPanel2.add(exPanel);
59
        jPanel2.add(treeTableView1);
60
        
60
        
61
        detailsPanel.setLayout(new java.awt.BorderLayout());
61
        detailsPanel.setLayout(new java.awt.BorderLayout());
62
        getExplorerManager().setRootContext(node);
62
        getExplorerManager().setRootContext(node);
Lines 71-83 Link Here
71
        
71
        
72
        node.addPropertyChangeListener(this);
72
        node.addPropertyChangeListener(this);
73
        try {
73
        try {
74
            selectedLookup = org.openide.util.lookup.Lookups.proxy (this);
75
            
74
            NodeAction globalMoveUp = (NodeAction)SystemAction.get(Class.forName("org.openide.actions.MoveUpAction")); // NOI18N
76
            NodeAction globalMoveUp = (NodeAction)SystemAction.get(Class.forName("org.openide.actions.MoveUpAction")); // NOI18N
75
            NodeAction globalMoveDown = (NodeAction)SystemAction.get(Class.forName("org.openide.actions.MoveDownAction")); // NOI18N
77
            NodeAction globalMoveDown = (NodeAction)SystemAction.get(Class.forName("org.openide.actions.MoveDownAction")); // NOI18N
76
            NodeAction globalNewAction = (NodeAction)SystemAction.get(Class.forName("org.openide.actions.NewAction")); // NOI18N
78
            NodeAction globalNewAction = (NodeAction)SystemAction.get(Class.forName("org.openide.actions.NewAction")); // NOI18N
77
            // Get context aware instances.
79
            // Get context aware instances.
78
            moveUp = globalMoveUp.createContextAwareInstance(exPanel.getLookup());
80
            moveUp = globalMoveUp.createContextAwareInstance(selectedLookup);
79
            moveDown = globalMoveDown.createContextAwareInstance(exPanel.getLookup());
81
            moveDown = globalMoveDown.createContextAwareInstance(selectedLookup);
80
            newAction = globalNewAction.createContextAwareInstance(exPanel.getLookup());
82
            newAction = globalNewAction.createContextAwareInstance(selectedLookup);
81
        } catch (ClassNotFoundException cnfe) {
83
        } catch (ClassNotFoundException cnfe) {
82
        }
84
        }
83
        
85
        
Lines 100-105 Link Here
100
        super.addNotify();
102
        super.addNotify();
101
        updateButtonState();
103
        updateButtonState();
102
    }
104
    }
105
    
106
    /** Returns the lookup of currently selected node.
107
     */
108
    public Lookup getLookup () {
109
        Node[] arr = getExplorerManager ().getSelectedNodes ();
110
        return arr.length == 1 ? arr[0].getLookup () : Lookup.EMPTY;
111
    }
103
112
104
    /** This method is called from within the constructor to
113
    /** This method is called from within the constructor to
105
     * initialize the form.
114
     * initialize the form.
Lines 285-290 Link Here
285
    private TreeTableView treeTableView1;
294
    private TreeTableView treeTableView1;
286
    
295
    
287
    private void updateButtonState() {
296
    private void updateButtonState() {
297
        // refresh the lookup
298
        selectedLookup.lookup (Object.class);
299
        
288
        if (showingDetails) {
300
        if (showingDetails) {
289
            detailsButton.setText(NbBundle.getBundle(IndexedEditorPanel.class).getString("CTL_HideDetails"));
301
            detailsButton.setText(NbBundle.getBundle(IndexedEditorPanel.class).getString("CTL_HideDetails"));
290
        } else {
302
        } else {
Lines 389-398 Link Here
389
    private boolean isEditorScrollable(PropertyPanel p) {
401
    private boolean isEditorScrollable(PropertyPanel p) {
390
        Component[] comps = p.getComponents();
402
        Component[] comps = p.getComponents();
391
        for (int i=0; i< comps.length; i++) {
403
        for (int i=0; i< comps.length; i++) {
392
            if ( comps[i] instanceof Scrollable || comps[i] instanceof TopComponent )
404
            if ( comps[i] instanceof Scrollable || isInstanceOfTopComponent (comps[i]))
393
                return true;
405
                return true;
394
        }
406
        }
395
        
407
        
396
        return false;
408
        return false;
397
    }
409
    }
410
411
    /** Checks whether an object is instanceof TopComponent 
412
     * @param obj the object
413
     * @return true or false
414
     */
415
    private static boolean isInstanceOfTopComponent (Object obj) {
416
        ClassLoader l = (ClassLoader)org.openide.util.Lookup.getDefault().lookup (ClassLoader.class);
417
        if (l == null) {
418
            l = IndexedEditorPanel.class.getClassLoader();
419
        }
420
        try {
421
            Class c = Class.forName ("org.openide.windows.TopComponent", true, l); // NOI18N
422
            return c.isInstance(obj);
423
        } catch (Exception ex) {
424
            return false;
425
        }
426
    }
427
    
398
}
428
}

Return to bug 35334