1 19 20 package org.netbeans.modules.xml.multiview.ui; 21 22 import javax.swing.*; 23 import java.awt.*; 24 25 31 public class TreePanelView extends PanelView { 32 33 java.util.HashMap map; 34 JPanel cardPanel; 35 CardLayout cardLayout; 36 public TreePanelView() { 37 super(); 38 } 39 40 public void initComponents() { 41 setLayout(new BorderLayout()); 42 cardLayout = new CardLayout(); 43 cardPanel = new JPanel(cardLayout); 44 map = new java.util.HashMap (); 45 JScrollPane scrollPane = new JScrollPane(); 46 scrollPane.setViewportView(cardPanel); 47 add (scrollPane, BorderLayout.CENTER); 48 } 49 50 public void showSelection(org.openide.nodes.Node[] nodes) { 51 if (nodes.length>0 && nodes[0] instanceof TreeNode) { 52 TreeNode node = (TreeNode)nodes[0]; 53 showPanel(node); 54 } 55 } 56 57 protected void showPanel(TreeNode node) { 58 String panelId = node.getPanelId(); 59 TreePanel treePanel = (TreePanel)map.get(panelId); 60 if (treePanel==null) { 61 treePanel = node.getPanel(); 62 map.put(panelId,treePanel); 63 cardPanel.add((JPanel)treePanel,panelId); 64 } 65 cardLayout.show(cardPanel, panelId); 66 treePanel.setModel(node); 67 } 68 69 protected org.netbeans.modules.xml.multiview.Error validateView() { 70 return null; 71 } 72 73 } 74 | Popular Tags |