/** * @param zooInspectorManager * - the {@link ZooInspectorManager} for the application * @param nodeVeiwers * - the {@link ZooInspectorNodeViewer}s to show */ public ZooInspectorNodeViewersPanel( ZooInspectorNodeManager zooInspectorManager, List<ZooInspectorNodeViewer> nodeVeiwers) { this.zooInspectorManager = zooInspectorManager; this.setLayout(new BorderLayout()); tabbedPane = new JTabbedPane(JTabbedPane.TOP, JTabbedPane.WRAP_TAB_LAYOUT); setNodeViewers(nodeVeiwers); tabbedPane.addChangeListener(this); this.add(tabbedPane, BorderLayout.CENTER); reloadSelectedViewer(); }
/** * @param nodeViewers * - the {@link ZooInspectorNodeViewer}s to show */ public void setNodeViewers(List<ZooInspectorNodeViewer> nodeViewers) { this.nodeVeiwers.clear(); this.nodeVeiwers.addAll(nodeViewers); needsReload.clear(); tabbedPane.removeAll(); for (ZooInspectorNodeViewer nodeViewer : nodeVeiwers) { nodeViewer.setZooInspectorManager(zooInspectorManager); needsReload.add(true); tabbedPane.add(nodeViewer.getTitle(), nodeViewer); } this.revalidate(); this.repaint(); }
private void reloadSelectedViewer() { int index = this.tabbedPane.getSelectedIndex(); if (index != -1 && this.needsReload.get(index)) { ZooInspectorNodeViewer viewer = this.nodeVeiwers.get(index); viewer.nodeSelectionChanged(selectedNodes); this.needsReload.set(index, false); } }