1 19 20 package org.netbeans.modules.openide.explorer; 21 22 import java.awt.BorderLayout ; 23 import java.awt.Component ; 24 import javax.swing.*; 25 26 import org.openide.explorer.propertysheet.PropertySheet; 27 import org.openide.explorer.view.BeanTreeView; 28 import org.openide.nodes.*; 29 import org.openide.util.UserCancelException; 30 31 34 public final class NodeOperationImpl extends org.openide.nodes.NodeOperation { 35 36 public boolean customize(Node node) { 37 Component customizer = node.getCustomizer(); 38 if (customizer == null) { 39 return false; 40 } 41 final JDialog d = new JDialog(); 42 d.setModal(false); 43 d.setTitle(node.getDisplayName()); 44 d.getContentPane().setLayout(new BorderLayout ()); 45 d.getContentPane().add(customizer, BorderLayout.CENTER); 46 d.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); 47 d.pack(); 48 d.setVisible(true); 49 return true; 50 } 51 52 public void explore(Node n) { 53 JDialog d = new JDialog(); 54 d.setTitle(n.getDisplayName()); 55 d.setModal(false); 56 d.getContentPane().setLayout(new BorderLayout ()); 57 EP p = new EP(); 58 p.getExplorerManager().setRootContext(n); 59 p.setLayout(new BorderLayout ()); 60 p.add(new JScrollPane(new BeanTreeView()), BorderLayout.CENTER); 61 d.getContentPane().add(p, BorderLayout.CENTER); 62 d.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); 63 d.pack(); 64 d.setVisible(true); 65 } 66 67 public Node[] select(String title, String rootTitle, Node root, NodeAcceptor acceptor, Component top) throws UserCancelException { 68 JDialog d = new JDialog(); 70 d.setTitle(title); 71 d.setModal(true); 72 d.getContentPane().setLayout(new BorderLayout ()); 73 EP p = new EP(); 74 p.getExplorerManager().setRootContext(root); 75 p.setLayout(new BorderLayout ()); 76 p.add(new JScrollPane(new BeanTreeView()), BorderLayout.CENTER); 77 d.getContentPane().add(p, BorderLayout.CENTER); 78 if (top != null) { 79 d.getContentPane().add(top, BorderLayout.NORTH); 80 } 81 d.pack(); 82 d.setVisible(true); 83 Node[] nodes = p.getExplorerManager().getSelectedNodes(); 84 d.dispose(); 85 return nodes; 86 } 87 88 public void showProperties(Node n) { 89 showProperties(new Node[] {n}); 90 } 91 92 public void showProperties(Node[] nodes) { 93 PropertySheet ps = new PropertySheet(); 94 ps.setNodes(nodes); 95 JDialog d = new JDialog(); 96 d.setTitle("Properties"); d.setModal(true); 98 d.getContentPane().setLayout(new BorderLayout ()); 99 d.getContentPane().add(ps, BorderLayout.CENTER); 100 d.pack(); 101 d.setVisible(true); 102 d.dispose(); 103 } 104 105 private static final class EP extends JPanel 106 implements org.openide.explorer.ExplorerManager.Provider { 107 private org.openide.explorer.ExplorerManager em = new org.openide.explorer.ExplorerManager (); 108 109 public org.openide.explorer.ExplorerManager getExplorerManager () { 110 return em; 111 } 112 } 113 } 114 | Popular Tags |