FileDocCategorySizeDatePackage
StackTracePanel.javaAPI DocAndroid 1.5 API9330Wed May 06 22:41:08 BST 2009com.android.ddmuilib

StackTracePanel

public final class StackTracePanel extends Object
Stack Trace Panel.

This is not a panel in the regular sense. Instead this is just an object around the creation and management of a Stack Trace display.

UI creation is done through {@link #createPanel(Composite, String, String, String, String, String, IPreferenceStore)}.

Fields Summary
private static ISourceRevealer
sSourceRevealer
private org.eclipse.swt.widgets.Table
mStackTraceTable
private org.eclipse.jface.viewers.TableViewer
mStackTraceViewer
private com.android.ddmlib.Client
mCurrentClient
Constructors Summary
Methods Summary
public org.eclipse.swt.widgets.TablecreatePanel(org.eclipse.swt.widgets.Composite parent, java.lang.String prefs_stack_col_class, java.lang.String prefs_stack_col_method, java.lang.String prefs_stack_col_file, java.lang.String prefs_stack_col_line, java.lang.String prefs_stack_col_native, org.eclipse.jface.preference.IPreferenceStore store)
Creates the controls for the StrackTrace display.

This method will set the parent {@link Composite} to use a {@link GridLayout} with 2 columns.

param
parent the parent composite.
param
prefs_stack_col_class
param
prefs_stack_col_method
param
prefs_stack_col_file
param
prefs_stack_col_line
param
prefs_stack_col_native
param
store

        
        mStackTraceTable = new Table(parent, SWT.MULTI | SWT.FULL_SELECTION);
        mStackTraceTable.setHeaderVisible(true);
        mStackTraceTable.setLinesVisible(true);
        
        TableHelper.createTableColumn(
                mStackTraceTable,
                "Class",
                SWT.LEFT,
                "SomeLongClassName", //$NON-NLS-1$
                prefs_stack_col_class, store);

        TableHelper.createTableColumn(
                mStackTraceTable,
                "Method",
                SWT.LEFT,
                "someLongMethod", //$NON-NLS-1$
                prefs_stack_col_method, store);

        TableHelper.createTableColumn(
                mStackTraceTable,
                "File",
                SWT.LEFT,
                "android/somepackage/someotherpackage/somefile.class", //$NON-NLS-1$
                prefs_stack_col_file, store);

        TableHelper.createTableColumn(
                mStackTraceTable,
                "Line",
                SWT.RIGHT,
                "99999", //$NON-NLS-1$
                prefs_stack_col_line, store);

        TableHelper.createTableColumn(
                mStackTraceTable,
                "Native",
                SWT.LEFT,
                "Native", //$NON-NLS-1$
                prefs_stack_col_native, store);
        
        mStackTraceViewer = new TableViewer(mStackTraceTable);
        mStackTraceViewer.setContentProvider(new StackTraceContentProvider());
        mStackTraceViewer.setLabelProvider(new StackTraceLabelProvider());
        
        mStackTraceViewer.addDoubleClickListener(new IDoubleClickListener() {
            public void doubleClick(DoubleClickEvent event) {
                if (sSourceRevealer != null && mCurrentClient != null) {
                    // get the selected stack trace element
                    ISelection selection = mStackTraceViewer.getSelection();
                    
                    if (selection instanceof IStructuredSelection) {
                        IStructuredSelection structuredSelection = (IStructuredSelection)selection;
                        Object object = structuredSelection.getFirstElement();
                        if (object instanceof StackTraceElement) {
                            StackTraceElement traceElement = (StackTraceElement)object;
                            
                            if (traceElement.isNativeMethod() == false) {
                                sSourceRevealer.reveal(
                                        mCurrentClient.getClientData().getClientDescription(), 
                                        traceElement.getClassName(),
                                        traceElement.getLineNumber());
                            }
                        }
                    }
                }
            }
        });

        return mStackTraceTable;
    
public voidsetCurrentClient(com.android.ddmlib.Client currentClient)
Sets the current client running the stack trace.

param
currentClient the {@link Client}.

        mCurrentClient = currentClient;
    
public static voidsetSourceRevealer(com.android.ddmuilib.StackTracePanel$ISourceRevealer revealer)
Sets the {@link ISourceRevealer} object able to reveal source code in a source editor.

param
revealer

        sSourceRevealer = revealer;
    
public voidsetViewerInput(com.android.ddmlib.IStackTraceInfo input)
Sets the input for the {@link TableViewer}.

param
input the {@link IStackTraceInfo} that will provide the viewer with the list of {@link StackTraceElement}

        mStackTraceViewer.setInput(input);
        mStackTraceViewer.refresh();