package DataLoader; //----------------------------------------------------------------------------------------------- import java.util.List; import java.util.Hashtable; import java.util.HashMap; import java.util.Arrays; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.border.*; import javax.swing.tree.*; import java.lang.*; import csplugins.isb.pshannon.experiment.metadata.*; //----------------------------------------------------------------------------------------------- public class ConditionTreeWizardPanel extends WizardPanel implements ActionListener { //----------------------------------------------------------------------------------------------- private static String repository = "httpIndirect://db.systemsbiology.net:8080/halo/DataFetcher.py"; protected MetaDataNavigator experimentNavigator; protected JTree tree; protected PerturbationNode rootNode; protected DefaultTreeModel treeModel; private static String INSERT_COMMAND = "Insert"; private static String REPLACE_COMMAND = "Replace"; private JTextField currentPerturbation; // private static String REMOVE_COMMAND = "Remove"; //----------------------------------------------------------------------------------------------- protected static class PerturbationNode extends DefaultMutableTreeNode{ private boolean isEditable; public PerturbationNode(Object a){ super(a); } public void setEditable(boolean b){ isEditable = b; } public boolean isEditable() { return isEditable; } }// class PerturbationNode //----------------------------------------------------------------------------------------------- public ConditionTreeWizardPanel(WizardContext wc) { setWizardContext(wc); setLayout(new BorderLayout()); setBorder(new TitledBorder("Step 2. Place Experiment Set Within the Condition Tree")); add(initTree(), BorderLayout.CENTER); JPanel treeStatusPanel = new JPanel(new GridLayout(0,1)); JPanel perturbationPanel = new JPanel(); perturbationPanel.add(new JLabel("Perturbation: ")); currentPerturbation = new JTextField(30); currentPerturbation.setEditable(false); perturbationPanel.add(currentPerturbation); JPanel treeButtonPanel = new JPanel(); JButton addNodeButton = new JButton(INSERT_COMMAND); addNodeButton.setActionCommand(INSERT_COMMAND); addNodeButton.addActionListener(this); JButton replaceNodeButton = new JButton(REPLACE_COMMAND); replaceNodeButton.setActionCommand(REPLACE_COMMAND); replaceNodeButton.addActionListener(this); /* JButton removeNodeButton = new JButton(REMOVE_COMMAND); removeNodeButton.setActionCommand(REMOVE_COMMAND); removeNodeButton.addActionListener(this); */ treeButtonPanel.add(addNodeButton); treeButtonPanel.add(replaceNodeButton); treeStatusPanel.add(treeButtonPanel); treeStatusPanel.add(perturbationPanel); add(treeStatusPanel, BorderLayout.SOUTH); }// constructor //----------------------------------------------------------------------------------------------- public JScrollPane initTree (){ try{ experimentNavigator = new MetaDataNavigator(repository); }catch (Exception e) { e.printStackTrace(); } rootNode = new PerturbationNode ("Experiments"); rootNode.setEditable(false); treeModel = new DefaultTreeModel(rootNode); treeModel.addTreeModelListener( new ExperimentTreeModelListener()); tree = new JTree (treeModel); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.setShowsRootHandles(true); HashMap experimentsTree = experimentNavigator.getTree(); createTree(rootNode, experimentsTree); JScrollPane scrollPane = new JScrollPane(tree); return scrollPane; }// initTree //----------------------------------------------------------------------------------------------- private void createTree (PerturbationNode root, HashMap e) { Object[] a = (e.keySet()).toArray(); Arrays.sort(a); for (int m=0;m