import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.JViewport;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
private jalview.ws.SequenceFetcher sfetcher;
+ private JLabel dbstatus;
+
public JDatabaseTree(jalview.ws.SequenceFetcher sfetch)
{
- super();
+ initDialogFrame(this, true, false, "Select Database Retrieval Source",
+ 650, 490);
/*
* Dynamically generated database list will need a translation function from
* internal source to externally distinct names. UNIPROT and UP_NAME are
{
tn.add(new DefaultMutableTreeNode(dbp, false));
ht.put(dbp.getDbName(), dbp.getDbName());
- } else {
- System.err.println("dupe ig for : "+dbs[i]+" \t"+dbp.getDbName());
+ }
+ else
+ {
+ System.err.println("dupe ig for : " + dbs[i] + " \t"
+ + dbp.getDbName());
}
}
}
}
root.add(tn);
}
- initDialogFrame(this, true, false, "Select Database Retrieval Source",
- 400, 300);
svp = new JScrollPane();
- //svp.setAutoscrolls(true);
+ // svp.setAutoscrolls(true);
dbviews = new JTree(new DefaultTreeModel(root, false));
dbviews.setCellRenderer(new DbTreeRenderer(this));
dbviews.getSelectionModel().setSelectionMode(
TreeSelectionModel.SINGLE_TREE_SELECTION);
svp.getViewport().setView(dbviews);
- svp.getViewport().setMinimumSize(new Dimension(300,250));
- //svp.setSize(300,250);
-// JPanel panel=new JPanel();
-// panel.setSize(new Dimension(350,220));
-// panel.add(svp);
-
- add(svp, BorderLayout.NORTH);
- JPanel j = new JPanel(new FlowLayout());
- j.setPreferredSize(new Dimension(300,50));
+ // svp.getViewport().setMinimumSize(new Dimension(300,200));
+ // svp.setSize(300,250);
+ // JPanel panel=new JPanel();
+ // panel.setSize(new Dimension(350,220));
+ // panel.add(svp);
+ dbviews.addTreeSelectionListener(new TreeSelectionListener()
+ {
+
+ @Override
+ public void valueChanged(TreeSelectionEvent arg0)
+ {
+ _setSelectionState();
+ }
+ });
+ JPanel jc = new JPanel(new BorderLayout()), j = new JPanel(
+ new FlowLayout());
+ jc.add(svp, BorderLayout.CENTER);
+
+ java.awt.Font f;
+ // TODO: make the panel resize and fit this in
+ dbstatus = new JLabel(" "); // set the height correctly for layout
+ dbstatus.setFont(f = JvSwingUtils.getLabelFont(false, true));
+ dbstatus.setSize(new Dimension(290, 50));
+ jc.add(dbstatus, BorderLayout.SOUTH);
+ jc.validate();
+ // j.setPreferredSize(new Dimension(300,50));
+ add(jc, BorderLayout.CENTER);
j.add(ok);
j.add(cancel);
- add(j, BorderLayout.CENTER);
+ add(j, BorderLayout.SOUTH);
validate();
}
}
}
}
+ updateDbStatus(srcs);
selection = srcs;
}
+ private void updateDbStatus(List<DbSourceProxy> srcs)
+ {
+ int x = 0;
+ for (DbSourceProxy dbs : srcs)
+ {
+ String tq = dbs.getTestQuery();
+ if (tq != null && tq.trim().length()>0 && dbs.isValidReference(tq))
+ {
+ x++;
+ }
+ }
+
+ dbstatus.setText("Selected "
+ + srcs.size()
+ + " database"
+ + (srcs.size() == 1 ? "" : "s")
+ + " to fetch from"
+ + (srcs.size() > 0 ? " with " + x + " test quer"
+ + (x == 1 ? "y" : "ies") : "."));
+ dbstatus.invalidate();
+ }
+
public String getSelectedItem()
{
if (hasSelection())