From: Lukas P. <pe...@us...> - 2002-08-23 18:15:17
|
Update of /cvsroot/javaprofiler/module/net/sourceforge/javaprofiler/module/nodes In directory usw-pr-cvs1:/tmp/cvs-serv20133 Added Files: BacktraceChildren.java BacktraceItemSheet.java Log Message: added cpu backtrace view --- NEW FILE: BacktraceChildren.java --- /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ package net.sourceforge.javaprofiler.module.nodes; import java.util.*; import org.openide.nodes.Children; import org.openide.nodes.AbstractNode; import org.openide.nodes.Node; import net.sourceforge.javaprofiler.jpi.*; import net.sourceforge.javaprofiler.module.nodes.CallTreeNode; import net.sourceforge.javaprofiler.module.data.BacktraceSupport; /** This children object is constructed from a list of <code>CPUTrace</code> * objects. Each child represents one FrameRef at a given level. * @author Lukas Petru */ public class BacktraceChildren extends Children.Array { private List traces; private int level; /** Constructs children. * @param list List of <code>CPUTrace</code>. * @param frameLevel Level of frame for which to create nodes. Level 1 is * the last called method in a trace. */ public BacktraceChildren(List list, int frameLevel) { traces=list; level=frameLevel; } protected Collection initCollection() { if (traces.size()==0) return Collections.EMPTY_LIST; java.util.Map map=BacktraceSupport.split(traces, level); traces=null; List nodeList=new ArrayList(); Iterator it=map.entrySet().iterator(); int i=1; while (it.hasNext()) { java.util.Map.Entry entry=(java.util.Map.Entry) it.next(); Node node=createBTNode(entry.getKey(), entry.getValue()); node.setName(String.valueOf(i++)); nodeList.add(node); } return nodeList; } private Node createBTNode(Object key, Object value) { FrameRef oo=(FrameRef) key; List bucket=(List) value; Children ch; if (bucket.size()==1 && ((TraceRef) bucket.get(0)).getFrames().size()<= level) ch=Children.LEAF; else ch=new BacktraceChildren(bucket, level+1); AbstractNode node=new CallTreeNode(ch, new BacktraceItemSheet(oo, bucket)); node.setDisplayName(oo.getMethod().toString() + oo.getMethod() .getSignature()); node.setIconBase( "/net/sourceforge/javaprofiler/module/resources/BacktraceItemIcon"); return node; } } /* * $Log: BacktraceChildren.java,v $ * Revision 1.1 2002/08/23 18:15:13 petrul * added cpu backtrace view * */ --- NEW FILE: BacktraceItemSheet.java --- /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ package net.sourceforge.javaprofiler.module.nodes; import java.util.List; import org.openide.TopManager; import org.openide.nodes.Node; import org.openide.nodes.Sheet; import org.openide.nodes.PropertySupport; import java.util.ResourceBundle; import org.openide.util.NbBundle; import net.sourceforge.javaprofiler.jpi.FrameRef; import net.sourceforge.javaprofiler.module.data.BacktraceSupport; import net.sourceforge.javaprofiler.jpi.CPUStat; /** Serves for creation of PropertySheet for call backtrace item. * @author Lukas Petru */ class BacktraceItemSheet implements SheetFactory { private FrameRef frRef; private List traces; /** Constructs a sheet from the given data. * @param ref Data of method and line number. * @param list List of <code>CPUStat</code> */ public BacktraceItemSheet(FrameRef ref, List list) { frRef=ref; traces=list; } public Sheet create() { ResourceBundle bundle=NbBundle.getBundle(BacktraceItemSheet.class); Sheet sh=new Sheet(); Sheet.Set set=Sheet.createPropertiesSet(); try { Node.Property pr=new PropertySupport.Reflection(frRef.getMethod() .getParentClass(), String.class, "getName", null); pr.setName("Class"); pr.setDisplayName(bundle.getString("LBL_BTItemClass")); set.put(pr); pr=new PropertySupport.Reflection(frRef.getMethod(), String.class, "getName", null); pr.setName("Method"); pr.setDisplayName(bundle.getString("LBL_BTItemMethodName")); set.put(pr); pr=new PropertySupport.Reflection(frRef.getMethod(), String.class, "getSignature", null); pr.setName("MethodSignature"); pr.setDisplayName(bundle.getString("LBL_BTItemMethodSignature")); set.put(pr); pr=new PropertySupport.Reflection(frRef, int.class, "getLineNo", null); pr.setName("LineNumber"); pr.setDisplayName(bundle.getString("LBL_CTItemLineNo")); set.put(pr); CPUStat stat=BacktraceSupport.getSumOfCPUStat(traces); CPUStatProperty.addProperties(set, stat); } catch (NoSuchMethodException e) { TopManager.getDefault().notifyException(e); } sh.put(set); return sh; } } /* * $Log: BacktraceItemSheet.java,v $ * Revision 1.1 2002/08/23 18:15:13 petrul * added cpu backtrace view * */ |