ZEST - How to recreate DotGraph Tree on event [message #870856] |
Thu, 10 May 2012 01:21 |
Menard Mabunga Messages: 7 Registered: January 2012 |
Junior Member |
|
|
Hi all,
Im developing a program that generates genealogy tree, my problem is that I cant recreate a tree upon events.
I have a GenealogyTree views, which displays blank tree in initial run of the program.
my GenealogyTree.class
@Override
public void createPartControl(Composite parent) {
// TODO Auto-generated method stub
SearchGermplasm searchGermplasm = (SearchGermplasm) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(SEARCH_VIEW);
graph = new DotGraph(parent, SWT.NONE);
algorithm = new TreeLayoutAlgorithm();
graph.setLayoutAlgorithm(algorithm, true);
con = searchGermplasm.getCon();
myGID = new Integer(searchGermplasm.getMyGID());
myLEVEL = searchGermplasm.getMyLEVEL();
loadTree(myGID, myLEVEL);
hookMenu(graph);
}
private void getParents(GermplasmPedigreeTreeNode currentChildNode, int level) throws QueryException
{
if(level > 0)
{
//get ID of this Germplasm for linking parent nodes to this child node
Germplasm rootChildGermplasm = currentChildNode.getGermplasm();
Integer childGermplasmID = rootChildGermplasm.getGid();
String childGermplasmName = rootChildGermplasm.getPreferredName().getNval();
for(GermplasmPedigreeTreeNode parentTreeNode : currentChildNode.getLinkedNodes())
{
parentGermplasm = parentTreeNode.getGermplasm();
System.out.println("Parent of : "+childGermplasmID+" is ---> " + parentGermplasm.getGid());
graph.add(childGermplasmID+"->"+parentGermplasm.getGid());
}
}
public void loadTree(int GID, int level) {
// TODO Auto-generated method stub
try {
tree = con.getManager().generatePedigreeTree(new Integer(GID), level);
} catch (QueryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
getParents(tree.getRoot(), level);
} catch (QueryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Now upon search events from SearchGermplasm.class, the user will define ID and LEVEL and will now the value of myGID and myLEVEL
method after clicking search button
public void setSGID(int sGID, int tLevel) throws QueryException, ConfigException
{
GenealogyTree genealogyTree = new GenealogyTree();
genealogyTree.createPartControl(btnSearch.getShell());
genealogyTree.loadTree(myGID, myLEVEL);
}
the method is working as its display all the list of parent and child records, but the problem is it doesnt display or recreate the tree.
Hope you all can help me with this.
Regards,
Menard Mabunga
|
|
|
|
Powered by
FUDForum. Page generated in 0.02064 seconds