|
What this is
Other links
The source code/* * 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 NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.examples.debugger.jpda.callstackviewfilterring; import java.util.ArrayList; import org.netbeans.api.debugger.jpda.CallStackFrame; import org.netbeans.spi.viewmodel.ComputingException; import org.netbeans.spi.viewmodel.NoInformationException; import org.netbeans.spi.viewmodel.NodeModel; import org.netbeans.spi.viewmodel.TreeModel; import org.netbeans.spi.viewmodel.TreeModelFilter; import org.netbeans.spi.viewmodel.TreeModelListener; import org.netbeans.spi.viewmodel.UnknownTypeException; public class CallStackFilter implements TreeModelFilter, NodeModel { public Object[] getChildren (TreeModel original, Object parent, int from, int to) throws NoInformationException, ComputingException, UnknownTypeException { Object[] originalCh = original.getChildren (parent, from, to); int i, k = originalCh.length; ArrayList newCh = new ArrayList (); boolean in = false; for (i = 0; i < k; i++) { if (! (originalCh [i] instanceof CallStackFrame)) { newCh.add (originalCh [i]); continue; } CallStackFrame f = (CallStackFrame) originalCh [i]; String className = f.getClassName (); if (className.startsWith ("java")) { if (!in) { newCh.add (new JavaFrames ()); in = true; } } else { in = false; newCh.add (f); } } return newCh.toArray (); } public Object getRoot (TreeModel original) { return original.getRoot (); } public boolean isLeaf (TreeModel original, Object node) throws UnknownTypeException { if (node instanceof JavaFrames) return true; return original.isLeaf (node); } public void addTreeModelListener (TreeModelListener l) { } public void removeTreeModelListener (TreeModelListener l) { } public String getDisplayName (Object node) throws UnknownTypeException { if (node instanceof JavaFrames) return "Java Callstack Frames"; throw new UnknownTypeException (node); } public String getIconBase (Object node) throws UnknownTypeException { if (node instanceof JavaFrames) return "org/netbeans/examples/debugger/jpda/callstackviewfilterring/NonCurrentFrame"; throw new UnknownTypeException (node); } public String getShortDescription (Object node) throws UnknownTypeException { if (node instanceof JavaFrames) return "Unimportant hidden callstack frames"; throw new UnknownTypeException (node); } private static class JavaFrames {} } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.