package com.c2kernel.gui.tabs.collection; import java.awt.GridLayout; import javax.swing.JSplitPane; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.DefaultMutableTreeNode; import com.c2kernel.collection.Collection; import com.c2kernel.collection.DependencyMember; import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.gui.MainFrame; import com.c2kernel.gui.TreeBrowser; import com.c2kernel.gui.tree.Node; import com.c2kernel.gui.tree.NodeCollection; import com.c2kernel.gui.tree.NodeItem; /** * @version $Revision: 1.2 $ $Date: 2005/06/02 12:17:22 $ * @author $Author: abranson $ */ public class DependencyView extends CollectionView { TreeBrowser tree; CollectionMemberPropertyPanel propPanel; JSplitPane split; public DependencyView() { super(); setLayout(new GridLayout(1, 1)); createLayout(); } @Override public void setCollection(Collection contents) { thisColl = contents; NodeCollection collNode = new NodeCollection(item, thisColl.getName(), null); tree = new TreeBrowser(MainFrame.myDesktopManager, collNode); tree.getTree().addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { if (e.getPath() == null) { propPanel.clear(); } else { Node selectedNode = (Node)((DefaultMutableTreeNode)e.getPath().getLastPathComponent()).getUserObject(); if (selectedNode instanceof NodeItem) { NodeItem thisItem = (NodeItem)selectedNode; if (thisItem.getParentCollection() != null) { try { propPanel.setMember(thisItem.getParentCollection().getMember(thisItem.getSlotNo())); return; } catch (ObjectNotFoundException e1) { } } propPanel.clear(); } } } }); split.setLeftComponent(tree); } public void createLayout() { propPanel = new CollectionMemberPropertyPanel(); split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.setRightComponent(propPanel); add(split); } }