KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > views > registers > RegistersViewContentProvider


1 /**********************************************************************
2  * Copyright (c) 2004 QNX Software Systems and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * QNX Software Systems - Initial API and implementation
10 ***********************************************************************/

11 package org.eclipse.debug.internal.ui.views.registers;
12
13 import org.eclipse.debug.core.DebugException;
14 import org.eclipse.debug.core.model.IRegisterGroup;
15 import org.eclipse.debug.core.model.IStackFrame;
16 import org.eclipse.debug.core.model.IVariable;
17 import org.eclipse.debug.internal.ui.DebugUIPlugin;
18 import org.eclipse.debug.internal.ui.views.IDebugExceptionHandler;
19 import org.eclipse.debug.internal.ui.views.variables.VariablesViewContentProvider;
20 import org.eclipse.debug.ui.IDebugView;
21
22 /**
23  * Provides contents for the registers view
24  */

25 public class RegistersViewContentProvider extends VariablesViewContentProvider {
26
27     public RegistersViewContentProvider(IDebugView view) {
28         super(view);
29     }
30
31     /**
32      * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
33      */

34     public Object JavaDoc[] getChildren(Object JavaDoc parent) {
35         Object JavaDoc[] children= null;
36         try {
37             if (parent instanceof IStackFrame) {
38                 children = ((IStackFrame)parent).getRegisterGroups();
39             } else if (parent instanceof IRegisterGroup) {
40                 children = ((IRegisterGroup)parent).getRegisters();
41             } else if (parent instanceof IVariable) {
42                 children = super.getChildren( parent );
43             }
44             if (children != null) {
45                 cache(parent, children);
46                 return children;
47             }
48         } catch (DebugException de) {
49             if (getExceptionHandler() != null) {
50                 getExceptionHandler().handleException(de);
51             } else {
52                 DebugUIPlugin.log(de);
53             }
54         }
55         return new Object JavaDoc[0];
56     }
57
58     /**
59      * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
60      */

61     public boolean hasChildren(Object JavaDoc element) {
62         try {
63             if (element instanceof IStackFrame) {
64                 return ((IStackFrame)element).hasRegisterGroups();
65             }
66             if (element instanceof IRegisterGroup) {
67                 return ((IRegisterGroup)element).hasRegisters();
68             }
69         } catch (DebugException de) {
70             DebugUIPlugin.log(de);
71             return false;
72         }
73         return super.hasChildren(element);
74     }
75
76     /**
77      * @see org.eclipse.debug.internal.ui.views.variables.VariablesViewContentProvider#setExceptionHandler(org.eclipse.debug.internal.ui.views.IDebugExceptionHandler)
78      */

79     protected void setExceptionHandler(IDebugExceptionHandler handler) {
80         super.setExceptionHandler(handler);
81     }
82 }
83
Popular Tags